Repository navigation
fix: add created timestamps to protobuf histograms and summaries - #2709
Open
Tanishq-Choudhary wants to merge 1 commit into
Open
Tanishq-Choudhary wants to merge 1 commit into
Tanishq-Choudhary wants to merge 1 commit into
Conversation
The protobuf writer sets `created_timestamp` on counters only. `Histogram` and `Summary` both record a created timestamp, and the `io.prometheus.client.Histogram` and `Summary` messages both have a `created_timestamp` field, but the writer drops it. The OpenMetrics text writer already exposes `_created` for both types. Prometheus reads this field for counters, summaries and histograms (including gauge histograms) when created timestamp zero ingestion is on, so histogram and summary series from client_java never got a synthetic zero sample. The writer now sets the field for histogram and summary data points the same way it does for counters. Signed-off-by: Tanishq Choudhary <tanishqchoudhary007@gmail.com>
Tanishq-Choudhary
requested review from
dhoard,
fstab,
jaydeluca and
zeitlinger
as code owners
November 19, 2026 15:13
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.
The protobuf writer only sets
created_timestampon counters (#1532).HistogramandSummaryrecord a created timestamp too, and theHistogramandSummarymessages inmetrics.protoboth have acreated_timestampfield, butPrometheusProtobufWriterImpldrops it. The OpenMetrics writer already exposes_createdfor both types.Prometheus reads this field (called
start_timestampthere now) for counters, summaries, histograms and gauge histograms (ProtobufParser.StartTimestamp()inmodel/textparse/protobufparse.go). So with created timestamp zero ingestion on, histogram and summary series from client_java never get the synthetic zero sample, while counters do. #1498 asked for the created timestamp in protobuf in general, and the answer there was that it can always be included for protobuf.Repro on main:
Fix: set the field in the histogram and summary
convertmethods, the same way the counter one does. Gauge histograms get it too, which matches what the OpenMetrics writer does with_created.Tests:
ExpositionFormatsTest: the protobuf expectations intestSummaryComplete,testClassicHistogramComplete,testClassicGaugeHistogramCompleteandtestNativeHistogramCompletenow includecreated_timestamp. These four fail on main and pass with the fix.HistogramTest: the client_golang test cases andtestDefaultscheck that the created timestamp is there, then clear it before comparing, so the copied golden strings stay as they are.Ran unit tests for config, model, exposition-textformats, exposition-formats, core, exporter-common, exporter-httpserver and simpleclient-bridge, plus google-java-format, checkstyle and the errorprone profile on the changed files. I didn't run the Docker integration tests;
debug-protobuf.txtonly has a counter, info and gauge, so it isn't affected.