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

[TraceQL] Add support for querying by instrumentation scope #3967

Merged
merged 9 commits into from
Aug 21, 2024

Conversation

ie-pham
Copy link
Contributor

@ie-pham ie-pham commented Aug 14, 2024

What this PR does: Add TraceQL to search by instrumentation scope name, version, and attributes.
Screenshot 2024-08-20 at 4 14 52 PM

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
@joe-elliott
Copy link
Member

cc @knylander-grafana possibly merged before 2.6 and would be a big feature

@@ -94,6 +94,8 @@ The following table shows the current available scoped intrinsic fields:
| `event:timeSinceStart` | duration | time of event in relation to the span start time | `{ event:timeSinceStart > 2ms}` |
| `link:spanID` | string | link span id using hex string | `{ link:spanID = "0000000000000001" }` |
| `link:traceID` | string | link trace id using hex string | `{ link:traceID = "1234567890abcde" }` |
| `scope:name` | string | instrumentation scope name | `{ scope:name = "grpc" }` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the thing at the left of : was a scope , i.e. link is a possible value for scope.
So is very confusing for me that this is called scope , shouldn't it be called instrumentation ?
instrumentation:name instrumentation:version more clearly define what this points at IMHO

Copy link
Member

@joe-elliott joe-elliott Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good call out. we have discussed this with our internal team and they believe that otel does not see this as an instrumentation only field. it just happens to be used that way and they intend for it to be used as a more generic "scope" long term.

agree that scope scope is strange. let me summon @jpkrohling. he may have more insight.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are end-users exposed to "scope scope"? As an OTel user, I immediately thought of InstrumentationScope when I saw "scope:name" here. Unless there's an explicit source of confusion, I'd keep "scope:name".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are end-users exposed to "scope scope"?

Not directly although there may be some awkward wording in the docs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally scope:name is a generic term that says nothing to me.
I can imagine for people better versed in opentelemetry parlance it is very obvious.
I am very sure that around here I will need to tell people that "scope:name means the name of the instrumentation/area that created the span". or such explanation as I do not think it is clear to more casual users of observability tools.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to have these differences called out in the doc to avoid confusion? Or would that just create more confusion?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs will definitely need to be there.
When someone reads a query or an autocomplete with span:duration , that person needs to know almost nothing about tracing to understand what that would mean, without resorting to reading documentation.

I think when someone reads scope:name that person will definitely need to go to documentation to know what would that mean.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the number of keyboard touches, I have no strong preferences for scope vs. instrumentation. They are both technically correct. If instrumentation is more intuitive to the audience, that certainly wins over scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcarres-mdsol thank you for pointing this out. I've changed the syntax to instrumentation:name and instrumentation:version 🚀

@@ -94,6 +94,8 @@ The following table shows the current available scoped intrinsic fields:
| `event:timeSinceStart` | duration | time of event in relation to the span start time | `{ event:timeSinceStart > 2ms}` |
| `link:spanID` | string | link span id using hex string | `{ link:spanID = "0000000000000001" }` |
| `link:traceID` | string | link trace id using hex string | `{ link:traceID = "1234567890abcde" }` |
| `scope:name` | string | instrumentation scope name | `{ scope:name = "grpc" }` |
| `scope:version` | string | instrumentation scope version | `{ scope:version = "1.0.0.0" }` |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was one .0 accidentally added?

Suggested change
| `scope:version` | string | instrumentation scope version | `{ scope:version = "1.0.0.0" }` |
| `scope:version` | string | instrumentation scope version | `{ scope:version = "1.0.0" }` |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor

@knylander-grafana knylander-grafana left a 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 docs! Approving the docs only.

@knylander-grafana knylander-grafana added the type/docs Improvements or additions to documentation label Aug 21, 2024
Copy link
Contributor

@mdisibio mdisibio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running locally things are looking good, searching, autocomplete, and selectall via compare() (nice!). Approving ✅

But did want to call out some unexpected behavior, that this PR is not causing, but unearthing. If a span is sent with no instrumentation, we save name/value to parquet as empty strings, and they are maintained for reads. Empty string is returned from autocomplete /api/v2/search/tag/instrumentation:name/values and /api/v2/search/tag/instrumentation:version/values, and the query {instrumentation:name="" && instrumentation:version=""} finds these spans.

But I think we got lucky. Although this behavior is unexpected, it's technically correct. The otel proto definition is commented Semantically when InstrumentationScope isn't set, it is equivalent with an empty instrumentation scope name (unknown). Now it's sounding familiar and we likely considered this when designing vParquet1 schema to be non-nullable (which this inherited).

Either way, I think we are good and just wanted to mention it for future reference.

@ie-pham ie-pham merged commit fbf249a into grafana:main Aug 21, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Improvements or additions to documentation
7 participants