Skip to content

Commit

Permalink
Add src_name and dst_name for attribute filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
grcevski committed Sep 11, 2024
1 parent 77cba46 commit e4180ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/internal/filter/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func newFilter[T any](config AttributeFamilyConfig, getters attributes.NamedGett
for attrStr, match := range config {
normalAttr, ok := attrProm2Normal[attr.Name(attrStr).Prom()]
if !ok {
return nil, fmt.Errorf("attribute filter: unknown attribute name %q", attrStr)
return nil, fmt.Errorf("attribute filter: unknown attribute name %q, available: %v", attrStr, attrProm2Normal)
}
matcher, err := buildMatcher(getters, normalAttr, &match)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/internal/request/span_getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ func SpanOTELGetters(name attr.Name) (attributes.Getter[*Span, attribute.KeyValu
getter = func(s *Span) attribute.KeyValue { return semconv.HTTPRoute(s.Route) }
case attr.HTTPUrlPath:
getter = func(s *Span) attribute.KeyValue { return HTTPUrlPath(s.Path) }
case attr.SrcName:
fallthrough
case attr.ClientAddr:
getter = func(s *Span) attribute.KeyValue { return ClientAddr(SpanPeer(s)) }
case attr.DstName:
fallthrough
case attr.ServerAddr:
getter = func(s *Span) attribute.KeyValue { return ServerAddr(SpanHost(s)) }
case attr.ServerPort:
Expand Down Expand Up @@ -124,8 +128,12 @@ func SpanPromGetters(attrName attr.Name) (attributes.Getter[*Span, string], bool
getter = func(s *Span) string { return s.Route }
case attr.HTTPUrlPath:
getter = func(s *Span) string { return s.Path }
case attr.SrcName:
fallthrough
case attr.ClientAddr:
getter = SpanPeer
case attr.DstName:
fallthrough
case attr.ServerAddr:
getter = SpanHost
case attr.ServerPort:
Expand Down

0 comments on commit e4180ae

Please sign in to comment.