feat: compositeValues and exemplarCompliance flags for OM2 writer#1991
Open
zeitlinger wants to merge 4 commits intomainfrom
Open
feat: compositeValues and exemplarCompliance flags for OM2 writer#1991zeitlinger wants to merge 4 commits intomainfrom
zeitlinger wants to merge 4 commits intomainfrom
Conversation
- compositeValues=true: write Histogram/GaugeHistogram/Summary as a
single composite-value line per the OM2 spec, e.g.
foo {count:17,sum:324789.3,bucket:[0.1:8,0.25:10,+Inf:17]} st@0.5
GaugeHistogram uses gcount/gsum per spec. Replaces separate _bucket,
_count, _sum, _created lines; created timestamp moves inline as st@.
Exemplar (latest) is appended inline when present.
- exemplarCompliance=true: skip exemplars without a timestamp, as the
OM2 spec mandates timestamps on all exemplars (MUST).
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
When compositeValues=false, OM2 histogram and summary output is identical to OM1 format. Delegate to om1Writer instead of duplicating writeClassicHistogramBuckets, writeNonCompositeSummaryDataPoint, and writeCountAndSum. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Apply the same delegation pattern as histogram/summary: when exemplarCompliance=false (default), delegate writeScrapeTimestampAndExemplar and writeExemplar to om1Writer. When exemplarCompliance=true, apply the OM2 spec requirement (drop exemplars without timestamps) then delegate the actual writing to om1Writer.writeExemplar. Extracts writeExemplar from om1Writer.writeScrapeTimestampAndExemplar so OM2 can delegate exemplar formatting without duplicating it. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
4ac4e32 to
f1eba6f
Compare
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.
Fixes #1989
Summary
compositeValues=true: Histogram, GaugeHistogram, and Summary arewritten as a single composite-value line per the OM2 spec:
_bucketlines)gcount/gsumper spec (note: the tracking issuesays "count/sum" but the spec is explicit about
gcount/gsum)st@; no separate_createdline_bucket,_count,_sumlines emittedcompositeValues=false(default), output is unchanged from beforeexemplarCompliance=true: Exemplars without a timestamp are silentlydropped. The OM2 spec mandates that all exemplars MUST have a timestamp.
The 128-char LabelSet limit from OM1 was never enforced in the writer, so
no change needed there.
Test plan
testCompositeHistogram— basic single-line histogram outputtestCompositeHistogramWithLabelsTimestampAndCreated— labels, scrapetimestamp, and
st@start timestamptestCompositeHistogramWithExemplar— exemplar appended inlinetestCompositeGaugeHistogram—gcount/gsumfieldstestCompositeSummary— basic single-line summary outputtestCompositeSummaryWithCreatedAndExemplar—st@+ exemplartestExemplarComplianceSkipsExemplarWithoutTimestamp— compliance modedrops exemplars without timestamps; default mode still emits them