Repository navigation
lib/traceql: support unscoped attributes in TraceQL queries #264
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,15 @@ func (fc *filterCommon) String() string { | |
| return otelpb.ParentSpanIDField + `:=""` | ||
| } | ||
|
|
||
| // Unscoped attribute `.foo` reads the span attribute if the span has it, and the resource attribute otherwise, | ||
| // `.service.name` is mapped to the resource stream field below. | ||
| if attr, ok := strings.CutPrefix(fc.fieldName, "."); ok && fc.fieldName != ".service.name" { | ||
| spanFilter := filterCommon{fieldName: "span." + attr, op: fc.op, value: fc.value} | ||
| resourceFilter := filterCommon{fieldName: "resource." + attr, op: fc.op, value: fc.value} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tempo also looks at the instrumentation scope after the resource (protospan.go). So a span that has The issue only asks for span and resource, so this is fine as a follow-up. If you want to add it here, a third branch on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wrong here, sorry. I ran Tempo 3.1.0 with the same spans, and |
||
| spanField := quoteFieldNameIfNeeded(otelpb.SpanAttrPrefixField + attr) | ||
| return "(" + spanField + ":* and " + spanFilter.String() + " or " + spanField + `:"" and ` + resourceFilter.String() + ")" | ||
| } | ||
|
|
||
| // TraceQL's `attr = nil` / `attr != nil` map to LogsQL's empty-value and | ||
| // any-value filters respectively — the canonical forms per | ||
| // https://docs.victoriametrics.com/victorialogs/logsql/#empty-value-filter | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Dotted intrinsic names (
.name,.kind,.status,.duration) now fall into this unscoped-attribute branch and are resolved asspan_attr:/resource_attr:attribute lookups, while the same keywords without the dot resolve to the span name stream field (name),status_code,kind, or thedurationfield..status = "error"will never match the status intrinsic, and a span whose literal attribute is namedstatuswould now match where it previously didn't. Extend the special-case beyond.service.name(or remap these dotted forms to the intrinsic fields) so unscoped intrinsics keep intrinsic semantics.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Tempo, a leading
.means an attribute rather than an intrinsic. I checked this against Tempo 3.1.0:{.status = "error"}matches an attribute namedstatus, while bare{status = error}matches the built-in status field, which is the same behavior we have here