istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/zipkin/zipkin.go (about) 1 // Copyright Istio Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package zipkin 16 17 import ( 18 "testing" 19 20 "istio.io/istio/pkg/test/framework/components/cluster" 21 "istio.io/istio/pkg/test/framework/resource" 22 ) 23 24 // Instance represents a zipkin deployment on kube 25 type Instance interface { 26 resource.Resource 27 28 // QueryTraces gets at most number of limit most recent available traces from zipkin. 29 // spanName filters that only trace with the given span name will be included. 30 QueryTraces(limit int, spanName, annotationQuery string) ([]Trace, error) 31 } 32 33 type Config struct { 34 // Cluster to be used in a multicluster environment 35 Cluster cluster.Cluster 36 37 // HTTP Address of ingress gateway of the cluster to be used to install zipkin in. 38 IngressAddr string 39 } 40 41 // Span represents a single span, which includes span attributes for verification 42 // TODO(bianpengyuan) consider using zipkin proto api https://github.com/istio/istio/issues/13926 43 type Span struct { 44 SpanID string 45 ParentSpanID string 46 ServiceName string 47 Name string 48 ChildSpans []*Span 49 } 50 51 // Trace represents a trace by a collection of spans which all belong to that trace 52 type Trace struct { 53 Spans []Span 54 } 55 56 // New returns a new instance of zipkin. 57 func New(ctx resource.Context, c Config) (i Instance, err error) { 58 return newKube(ctx, c) 59 } 60 61 // NewOrFail returns a new zipkin instance or fails test. 62 func NewOrFail(t *testing.T, ctx resource.Context, c Config) Instance { 63 t.Helper() 64 i, err := New(ctx, c) 65 if err != nil { 66 t.Fatalf("zipkin.NewOrFail: %v", err) 67 } 68 69 return i 70 }