Repository navigation
Conversation
with(sample=f) volume metrics are comparable with unsampled ones: rate folds the factor into its divisor, count_over_time and sum_over_time multiply, the histogram scales its heights and not its bounds, and compare() scales both counts. min_over_time, max_over_time, avg_over_time, quantile_over_time and exemplars stay as they are. The factor comes from the hint, so it is the same under span and trace hashing. Scale 1 renders byte-identical SQL. Histogram heights and compare() counts are read as Float64, since a scale that is not a whole number gives non-integer values.
This was referenced Nov 9, 2026
This branch has not been deployed
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.
Follow-up to #1034's open question on sampled metrics. Based on
feat/traceql-structural-ops; merges into it as a merge commit.Summary
1/ffrom thewith(sample=f)hint, not an observed ratio, the same under span and trace hashing.rate,count_over_time,sum_over_time,histogram_over_timeheights (not bounds), andcompare()selection and baseline counts.min_over_time,max_over_time,avg_over_time,quantile_over_time.Scale float64(1 without a hint) on the metrics and compare requests, set fromSampleFraction()beside the sample filter. Scaled functions are wrapped as(expr) * k,ratefolds the scale into its divisor, and the histogram scales only its count.compare()counts becomeFloat64. Scale 1 renders byte-identical SQL. A hint so small that its hash threshold is 0 renders unsampled SQL.rateandcount_over_timehas as its value the series point of its step, which is scaled, so it sits on the plotted line. Exemplars of the other functions keep their unscaled values.1/f.Breaking changes
None: the
samplehint is new in #1034.Upgrade notes
None.
Evidence
TestExemplarValueUnderScalingpins the exemplar rule.go test ./...passes. The full e2e suite andgrid.traceqlpass on the full stack tip, against tests Is /loki/api/v1/push Schema different from Loki on purpose? #24, whose grid oracle scales by1/f.Merge Danger
Door: two-way.
Blast Radius: metrics and
compare()with asamplehint.sample=0.5counts (m_sample_span,m_sample_one_hop,m_sample_agg), which disagree with this branch. The oracle that scales by1/fis on tests Is /loki/api/v1/push Schema different from Loki on purpose? #24. Those three cases fail on this branch until the stack lands on Is /loki/api/v1/push Schema different from Loki on purpose? #24's pin.