-
Notifications
You must be signed in to change notification settings - Fork 495
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
Support quoted attribute in traceql #3004
Support quoted attribute in traceql #3004
Conversation
docs/sources/tempo/traceql/_index.md
Outdated
It's possible that attributes name can contain terminal characters, to search span attributes with terminal character you can use quoted attribute syntax. A quoted attirbute should be enclosed inside double quote and all characters between the quotes will be considered part of the attribute name. | ||
|
||
For example, to find span with attribute name `attribute name with space` one can use the following query |
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.
Thank you for adding documentation! These suggestions correct a few grammatical issues and separate run-on sentence. For more information, refer to the Writers' Toolkit.
It's possible that attributes name can contain terminal characters, to search span attributes with terminal character you can use quoted attribute syntax. A quoted attirbute should be enclosed inside double quote and all characters between the quotes will be considered part of the attribute name. | |
For example, to find span with attribute name `attribute name with space` one can use the following query | |
Attribute names can contain terminal characters, such as a period (`.`). To search span attributes with terminal characters, you can use quoted attribute syntax. A quoted attribute should be enclosed inside double quotes, for example, `"example one"`. All characters between the quotes are considered part of the attribute name. | |
For example, to find span with attribute name `attribute name with space`, you can use the following query: |
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.
Thanks a lot. 🙂 I have made the changes and will refer to the mentioned style guide going forward.
docs/sources/tempo/traceql/_index.md
Outdated
{ span.attribute."attribute name with space" = "value" } | ||
``` | ||
|
||
Note: Only `\"` and `\\` escape sequence are supported as of now. |
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.
This change uses the shortcode for a Note admonition. Using shortcodes helps us separate content from presentation. To learn more about the shortcode, refer to the Writers' Toolkit.
Note: Only `\"` and `\\` escape sequence are supported as of now. | |
{{% admonition type="note" %}} | |
Currently, only `\"` and `\\` escape sequence are supported. | |
{{% /admonition %}} |
CHANGELOG.md
Outdated
@@ -1,4 +1,5 @@ | |||
## main / unreleased | |||
* [ENHANCEMENT] Support quoted attribute name in traceql [#3004](https://github.com/grafana/tempo/pull/3004) (@kousikmitra) |
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.
Correcting capitalization for TraceQL.
* [ENHANCEMENT] Support quoted attribute name in traceql [#3004](https://github.com/grafana/tempo/pull/3004) (@kousikmitra) | |
* [ENHANCEMENT] Support quoted attribute name in TraceQL [#3004](https://github.com/grafana/tempo/pull/3004) (@kousikmitra) |
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.
Thank you for updating the doc! I've made some suggestions to help clarify the content you added. Please let me know if you have any questions.
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.
nice work! had some thoughts and questions
a5ba22c
to
3024f63
Compare
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.
Looks great! One last request. Can we get a test added at this level to really confirm everything is working as intended:
https://github.com/grafana/tempo/blob/main/tempodb/tempodb_search_test.go#L73
I linked the test that made the most sense to me, but if you want to put it in a different runner or add a new one you are welcome to.
pkg/traceql/lexer.go
Outdated
return sb.String(), nil | ||
} | ||
|
||
func tryScopeAtribute(l *scanner.Scanner) (int, bool) { |
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.
func tryScopeAtribute(l *scanner.Scanner) (int, bool) { | |
func tryScopeAttribute(l *scanner.Scanner) (int, bool) { |
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.
@knylander-grafana We might want to expand on the explanation of escape sequences. WDYT?
I've proposed some adjustments to the docs to fix some typos and remove some extraneous words.
docs/sources/tempo/traceql/_index.md
Outdated
@@ -119,6 +119,26 @@ For example, to find traces with an attribute of `sla` set to `critical`: | |||
{ .sla = "critical" } | |||
``` | |||
|
|||
### Quoted attribute names | |||
|
|||
Attribute names can contain terminal characters, such as a period (`.`). To search span attributes with terminal characters, you can use quoted attribute syntax. A quoted attribute should be enclosed inside double quotes, for example, `"example one"`. All characters between the quotes are considered part of the attribute name. |
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.
nit: Semantic line breaks are better for future line based diffing in the GitHub UI and result in the same HTML output.
Attribute names can contain terminal characters, such as a period (`.`). To search span attributes with terminal characters, you can use quoted attribute syntax. A quoted attribute should be enclosed inside double quotes, for example, `"example one"`. All characters between the quotes are considered part of the attribute name. | |
Attribute names can contain terminal characters, such as a period (`.`). | |
To search span attributes with terminal characters, you can use quoted attribute syntax. | |
A quoted attribute should be enclosed inside double quotes, for example, `"example one"`. | |
All characters between the quotes are considered part of the attribute name. |
docs/sources/tempo/traceql/_index.md
Outdated
For example, to find span with attribute name `attribute name with space`, you can use the following query: | ||
``` | ||
{ ."attribute name with space" = "value" } | ||
``` |
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.
For example, to find span with attribute name `attribute name with space`, you can use the following query: | |
``` | |
{ ."attribute name with space" = "value" } | |
``` | |
To find a span with the attribute name `attribute name with space`, use the following query: | |
``` | |
{ ."attribute name with space" = "value" } | |
``` |
docs/sources/tempo/traceql/_index.md
Outdated
You can use quoted attributes syntax with non-quoted attribute syntax. | ||
|
||
For example, the syntax below is a valid TraceQL query. | ||
``` | ||
{ span.attribute."attribute name with space" = "value" } | ||
``` |
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.
You can use quoted attributes syntax with non-quoted attribute syntax. | |
For example, the syntax below is a valid TraceQL query. | |
``` | |
{ span.attribute."attribute name with space" = "value" } | |
``` | |
You can use quoted attributes syntax with non-quoted attribute syntax, the following is a valid TraceQL query: | |
``` | |
{ span.attribute."attribute name with space" = "value" } | |
``` |
docs/sources/tempo/traceql/_index.md
Outdated
``` | ||
|
||
{{% admonition type="note" %}} | ||
Currently, only `\"` and `\\` escape sequence are supported. |
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.
Currently, only `\"` and `\\` escape sequence are supported. | |
Currently, only the `\"` and `\\` escape sequences are supported. |
Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
ebdd21a
to
44c9ca1
Compare
@joe-elliott @jdbaldry Made the requested changes. Let me know if this is ok. |
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.
Great work!
What this PR does:
This PR extends the traceql lexer to lex quoted attribute names (ex:
span."foo bar"
) this will help searching tempo with span attributes containing breaking characters like=, "
etc.Which issue(s) this PR fixes:
Fixes #2805
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]