Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added root.name and root.service.name support to v2 and parquet #1589

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Jsonnet users will now need to specify a storage request and limit for the gener
* [BUGFIX] Fix wal check on span name to be substring [#1548](https://github.com/grafana/tempo/pull/1548) (@mdisibio)
* [BUGFIX] Prevent ingester panic "cannot grow buffer" [#1258](https://github.com/grafana/tempo/issues/1258) (@mdisibio)
* [BUGFIX] metrics-generator: do not remove x-scope-orgid header in single tenant modus [#1554](https://github.com/grafana/tempo/pull/1554) (@kvrhdn)
* [BUGFIX] Fixed issue where backend does not support `root.name` and `root.service.name` [#1589](https://github.com/grafana/tempo/pull/1589) (@kvrhdn)

## v1.4.1 / 2022-05-05

Expand Down
25 changes: 25 additions & 0 deletions pkg/model/trace/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func MatchesProto(id []byte, trace *tempopb.Trace, req *tempopb.SearchRequest) (
// checks non attribute span properties for matching
matchSpan(tagsToFind, s)
matchAttributes(tagsToFind, s.Attributes)

// special root span check
if len(s.ParentSpanId) == 0 && b.Resource != nil {
matchRootServiceName(tagsToFind, b.Resource.Attributes)
}
}
}
}
Expand Down Expand Up @@ -142,6 +147,12 @@ func matchSpan(tags map[string]string, s *v1.Span) {
delete(tags, StatusCodeTag)
}
}

if name, ok := tags[RootSpanNameTag]; ok {
if strings.Contains(s.Name, name) && len(s.ParentSpanId) == 0 {
delete(tags, RootSpanNameTag)
}
}
}

// matchAttributes tests to see if any tags in the map match any passed attributes
Expand Down Expand Up @@ -184,3 +195,17 @@ func matchAttributes(tags map[string]string, atts []*v1common.KeyValue) {
}
}
}

func matchRootServiceName(tags map[string]string, atts []*v1common.KeyValue) {
name, ok := tags[RootServiceNameTag]
if !ok {
return
}

for _, a := range atts {
if a.Key == "service.name" && strings.Contains(a.Value.GetStringValue(), name) {
delete(tags, RootServiceNameTag)
return
}
}
}
4 changes: 4 additions & 0 deletions pkg/model/trace/search_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func SearchTestSuite() (
makeReq("k8s.namespace.name", "k8sNamespace"),
makeReq("k8s.pod.name", "k8sPod"),
makeReq("k8s.container.name", "k8sContainer"),
makeReq("root.service.name", "RootService"),
makeReq("root.name", "RootSpan"),

// Well-known span attributes
makeReq("name", "Span"),
Expand Down Expand Up @@ -214,6 +216,8 @@ func SearchTestSuite() (
makeReq("http.url", "asdf"),
makeReq("http.status_code", "200"),
makeReq("status.code", "ok"),
makeReq("root.service.name", "NotRootService"),
makeReq("root.name", "NotRootSpan"),

// Span attributes
makeReq("foo", "baz"), // wrong case
Expand Down
4 changes: 4 additions & 0 deletions tempodb/encoding/vparquet/block_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func makePipelineWithRowGroups(ctx context.Context, req *tempopb.SearchRequest,

for k, v := range req.Tags {
switch k {
case LabelRootServiceName:
traceIters = append(traceIters, makeIter("RootServiceName", pq.NewSubstringPredicate(v), ""))
case LabelRootSpanName:
traceIters = append(traceIters, makeIter("RootSpanName", pq.NewSubstringPredicate(v), ""))
case LabelServiceName:
resourceIters = append(resourceIters, makeIter("rs.Resource.ServiceName", pq.NewSubstringPredicate(v), ""))
case LabelCluster:
Expand Down
3 changes: 3 additions & 0 deletions tempodb/encoding/vparquet/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
// Label names for conversion b/n Proto <> Parquet

const (
LabelRootSpanName = "root.name"
LabelRootServiceName = "root.service.name"

LabelServiceName = "service.name"
LabelCluster = "cluster"
LabelNamespace = "namespace"
Expand Down