diff --git a/processor/filterprocessor/filter_processor_traces.go b/processor/filterprocessor/filter_processor_traces.go index c257b2dcb7c0..617dd0132708 100644 --- a/processor/filterprocessor/filter_processor_traces.go +++ b/processor/filterprocessor/filter_processor_traces.go @@ -81,7 +81,7 @@ func (fsp *filterSpanProcessor) processTraces(_ context.Context, pdt pdata.Trace ils := resSpan.InstrumentationLibrarySpans().At(x) for spanCount := 0; spanCount < ils.Spans().Len(); spanCount++ { ils.Spans().RemoveIf(func(span pdata.Span) bool { - return !filterspan.SkipSpan(fsp.include, fsp.exclude, span, resSpan.Resource(), ils.InstrumentationLibrary()) + return !fsp.shouldKeepSpan(span, resSpan.Resource(), ils.InstrumentationLibrary()) }) } } @@ -94,3 +94,19 @@ func (fsp *filterSpanProcessor) processTraces(_ context.Context, pdt pdata.Trace } return pdt, nil } + +func (fsp *filterSpanProcessor) shouldKeepSpan(span pdata.Span, resource pdata.Resource, library pdata.InstrumentationLibrary) bool { + if fsp.include != nil { + if i := fsp.include.MatchSpan(span, resource, library); !i { + return false + } + } + + if fsp.exclude != nil { + if e := fsp.exclude.MatchSpan(span, resource, library); e { + return false + } + } + + return true +}