Skip to content

Commit

Permalink
Clear up keep logic
Browse files Browse the repository at this point in the history
Signed-off-by: John <john.dorman@sony.com>
  • Loading branch information
boostchicken authored and jpkrohling committed Jan 18, 2022
1 parent e2e5d49 commit 7c26c95
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion processor/filterprocessor/filter_processor_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}
}
Expand All @@ -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
}

0 comments on commit 7c26c95

Please sign in to comment.