Skip to content

Commit

Permalink
Check resource and span for service.name
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 2f3912a commit 00bc404
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/coreinternal/processor/filterspan/filterspan.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func SkipSpan(include Matcher, exclude Matcher, span pdata.Span, resource pdata.
func (mp *propertiesMatcher) MatchSpan(span pdata.Span, resource pdata.Resource, library pdata.InstrumentationLibrary) bool {
// If a set of properties was not in the mp, all spans are considered to match on that property
if mp.serviceFilters != nil {
serviceName := serviceNameForResource(resource)
// Check resource and spans for service.name
serviceName := serviceNameForResource(resource, span)
if !mp.serviceFilters.Matches(serviceName) {
return false
}
Expand All @@ -124,11 +125,14 @@ func (mp *propertiesMatcher) MatchSpan(span pdata.Span, resource pdata.Resource,
return mp.PropertiesMatcher.Match(span.Attributes(), resource, library)
}

// serviceNameForResource gets the service name for a specified Resource.
func serviceNameForResource(resource pdata.Resource) string {
// serviceNameForResource gets the service name for a specified Resource and its associated Span.
func serviceNameForResource(resource pdata.Resource, span pdata.Span) string {
service, found := resource.Attributes().Get(conventions.AttributeServiceName)
if !found {
return "<nil-service-name>"
service, found = span.Attributes().Get(conventions.AttributeServiceName)
if !found {
return "<nil-service-name>"
}
}

return service.StringVal()
Expand Down

0 comments on commit 00bc404

Please sign in to comment.