MCPcopy
hub / github.com/grafana/tempo / NewSpanFilter

Function NewSpanFilter

pkg/spanfilter/spanfilter.go:20–59  ·  view source on GitHub ↗

NewSpanFilter returns a SpanFilter that will filter spans based on the given filter policies.

(filterPolicies []config.FilterPolicy)

Source from the content-addressed store, hash-verified

18
19// NewSpanFilter returns a SpanFilter that will filter spans based on the given filter policies.
20func NewSpanFilter(filterPolicies []config.FilterPolicy) (*SpanFilter, error) {
21 sf := new(SpanFilter)
22 for _, policy := range filterPolicies {
23 err := config.ValidateFilterPolicy(policy)
24 if err != nil {
25 return nil, err
26 }
27
28 include, err := getSplitPolicy(policy.Include)
29 if err != nil {
30 return nil, err
31 }
32
33 if include != nil {
34 sf.include = append(sf.include, include)
35 sf.hasInclude = true
36 }
37
38 includeAny, err := getSplitPolicy(policy.IncludeAny)
39 if err != nil {
40 return nil, err
41 }
42
43 if includeAny != nil {
44 sf.includeAny = append(sf.includeAny, includeAny)
45 sf.hasIncludeAny = true
46 }
47
48 exclude, err := getSplitPolicy(policy.Exclude)
49 if err != nil {
50 return nil, err
51 }
52 if exclude != nil {
53 sf.exclude = append(sf.exclude, exclude)
54 sf.hasExclude = true
55 }
56 }
57
58 return sf, nil
59}
60
61// ApplyFilterPolicy returns true if the span should be included in the metrics.
62func (f *SpanFilter) ApplyFilterPolicy(rs *v1.Resource, span *tracev1.Span) bool {

Callers 6

NewFunction · 0.92
NewFunction · 0.92
ValidateFilterPoliciesFunction · 0.92
benchmarkFilterPolicyFunction · 0.85

Calls 2

ValidateFilterPolicyFunction · 0.92
getSplitPolicyFunction · 0.85

Tested by 3

benchmarkFilterPolicyFunction · 0.68