-
Notifications
You must be signed in to change notification settings - Fork 577
TraceQL Metrics: right exemplars for histogram and quantiles #5145
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
Merged
ruslan-mikhailov
merged 10 commits into
grafana:main
from
ruslan-mikhailov:bugfix/histogram-exemplars
Jun 2, 2025
Merged
TraceQL Metrics: right exemplars for histogram and quantiles #5145
ruslan-mikhailov
merged 10 commits into
grafana:main
from
ruslan-mikhailov:bugfix/histogram-exemplars
Jun 2, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e707cd9
to
30d22d1
Compare
mdisibio
reviewed
May 22, 2025
04755c4
to
ed202d0
Compare
+ review fixes |
ed202d0
to
68316ef
Compare
+ rebase from latest master |
mdisibio
reviewed
May 23, 2025
This was referenced May 26, 2025
+ benchmarks |
+ review fix |
d00396c
to
fad8276
Compare
+ gosec overflow linter mute for testing function |
fad8276
to
2bf9905
Compare
mdisibio
approved these changes
May 29, 2025
2bf9905
to
e4faa25
Compare
+ rebase from latest main |
ruslan-mikhailov
added a commit
to ruslan-mikhailov/tempo
that referenced
this pull request
Jun 2, 2025
…#5145) * Minor: remove forgotten comment * [Bugfix] TraceQL Metrics: right exemplars for histogram and quantiles * Test fixes: correct unmarshaller * Tests: send traces with different attributes * Tests: by operation * Test attribute values in exemplars * Changelog * Test attribute values in exemplars: additional cases * Benchmarks: HistogramAggregator.Combine * Minor review improvement
3 tasks
ruslan-mikhailov
added a commit
to ruslan-mikhailov/tempo
that referenced
this pull request
Jun 2, 2025
…#5145) * Minor: remove forgotten comment * [Bugfix] TraceQL Metrics: right exemplars for histogram and quantiles * Test fixes: correct unmarshaller * Tests: send traces with different attributes * Tests: by operation * Test attribute values in exemplars * Changelog * Test attribute values in exemplars: additional cases * Benchmarks: HistogramAggregator.Combine * Minor review improvement
ruslan-mikhailov
added a commit
that referenced
this pull request
Jun 2, 2025
…5197) * Minor: remove forgotten comment * [Bugfix] TraceQL Metrics: right exemplars for histogram and quantiles * Test fixes: correct unmarshaller * Tests: send traces with different attributes * Tests: by operation * Test attribute values in exemplars * Changelog * Test attribute values in exemplars: additional cases * Benchmarks: HistogramAggregator.Combine * Minor review improvement
knylander-grafana
pushed a commit
to knylander-grafana/tempo-doc-work
that referenced
this pull request
Jun 2, 2025
…#5145) * Minor: remove forgotten comment * [Bugfix] TraceQL Metrics: right exemplars for histogram and quantiles * Test fixes: correct unmarshaller * Tests: send traces with different attributes * Tests: by operation * Test attribute values in exemplars * Changelog * Test attribute values in exemplars: additional cases * Benchmarks: HistogramAggregator.Combine * Minor review improvement
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
Root cause
In this loop: https://github.com/ruslan-mikhailov/tempo/blob/17e20a43af0881ef0841d2e33eaeb190c422e549/pkg/traceql/engine_metrics.go#L1477
it iterates over the series set while putting all the exemplars into each resulting series without any filtration: https://github.com/ruslan-mikhailov/tempo/blob/17e20a43af0881ef0841d2e33eaeb190c422e549/pkg/traceql/engine_metrics.go#L1488
For example, if in total, we have the following exemplars:
E1 - span_attr=val_A
E2 - span_attr=val_A
E3 - span_attr=val_B
E4 - span_attr=val_C
For the following query:
we have:
val_A time series exemplars: E1,E2,E3,E4
val_B time series exemplars: E1,E2,E3,E4
val_C time series exemplars: E1,E2,E3,E4
Expected results:
val_A time series exemplars: E1,E2
val_B time series exemplars: E3
val_C time series exemplars: E4
Impact
In Grafana UI, after filtering by series, it provides wrong exemplars from another series, misleading users and providing a bad UX.
How it has been tested
Unit tests (in the PR)
Check that all exemplars have an attribute label that matches the corresponding time series label.
Manual testing
example/docker-compose/local
Python script
span.db.system
label in exemplars matches"promLabels"
of the seriesMain branch results:
After the fix, only exemplars like this:
Which issue(s) this PR fixes
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]