github.com/cilium/cilium@v1.16.2/pkg/hubble/filters/tracing.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Hubble 3 4 package filters 5 6 import ( 7 "context" 8 9 flowpb "github.com/cilium/cilium/api/v1/flow" 10 v1 "github.com/cilium/cilium/pkg/hubble/api/v1" 11 ) 12 13 func filterByTraceID(tids []string) FilterFunc { 14 return func(ev *v1.Event) bool { 15 traceID := ev.GetFlow().GetTraceContext().GetParent().GetTraceId() 16 for _, tid := range tids { 17 if tid == traceID { 18 return true 19 } 20 } 21 return false 22 } 23 } 24 25 // TraceIDFilter implements filtering based on trace IDs. 26 type TraceIDFilter struct{} 27 28 // OnBuildFilter builds a trace ID filter. 29 func (t *TraceIDFilter) OnBuildFilter(_ context.Context, ff *flowpb.FlowFilter) ([]FilterFunc, error) { 30 var fs []FilterFunc 31 if tids := ff.GetTraceId(); tids != nil { 32 fs = append(fs, filterByTraceID(tids)) 33 } 34 return fs, nil 35 }