TraceQL Metrics: right exemplars for histogram and quantiles#5145
Merged
ruslan-mikhailov merged 10 commits intografana:mainfrom Jun 2, 2025
Merged
TraceQL Metrics: right exemplars for histogram and quantiles#5145ruslan-mikhailov merged 10 commits intografana:mainfrom
ruslan-mikhailov merged 10 commits intografana:mainfrom
Conversation
e707cd9 to
30d22d1
Compare
mdisibio
reviewed
May 22, 2025
04755c4 to
ed202d0
Compare
Contributor
Author
|
+ review fixes |
ed202d0 to
68316ef
Compare
Contributor
Author
|
+ rebase from latest master |
mdisibio
reviewed
May 23, 2025
This was referenced May 26, 2025
Contributor
Author
|
+ benchmarks |
Contributor
Author
|
+ review fix |
d00396c to
fad8276
Compare
Contributor
Author
|
+ gosec overflow linter mute for testing function |
fad8276 to
2bf9905
Compare
mdisibio
approved these changes
May 29, 2025
2bf9905 to
e4faa25
Compare
Contributor
Author
|
+ 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
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
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/localPython script
span.db.systemlabel 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.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]