client_java icon indicating copy to clipboard operation
client_java copied to clipboard

Feature Request: Support `createdTimestampMillis` in `PrometheusProtobufWriterImpl`

Open cmaune opened this issue 5 months ago • 4 comments

Background:

We're using Spring Boot 3.5.x with Micrometer 1.15.2, and would like to leverage the createdTimestamp feature introduced behind a feature flag on the Prometheus server.

On Prometheus server side this feature is only available if the Prometheus Protobuf Protocol is used.

In the Prometheus Java client, we noticed that the PrometheusProtobufWriterImpl currently only maps scrapeTimestampMillis from the DataPointSnapshot, but not the available createdTimestampMillis.

What we did:

We tested adding support for createdTimestampMillis in a fork of the latest release and confirmed that our counter metrics are now exposed with an initialized value of 0 as expected. This also builds on recent support added to Micrometer for this field (micrometer-metrics/micrometer#2625).

Proposal:

We propose updating PrometheusProtobufWriterImpl to also map and include createdTimestampMillis, similar to how scrapeTimestampMillis is currently handled. This would improve compatibility with Prometheus’ feature flag and help downstream libraries like Micrometer to fully support this newer functionality.

Would you be open to a PR for this? We're happy to contribute the necessary change if desired.

Thanks for your great work on this library!

cmaune avatar Aug 08 '25 17:08 cmaune

Yes that sounds great!

zeitlinger avatar Aug 11 '25 08:08 zeitlinger

We got a question about the desired implementation. The necessary adjustment we want to be available is: https://github.com/prometheus/client_java/commit/6043873ab07a5550f2d3d7cf5266d060ff9bb3d1.

Looking at the test changes needed in several places, like the (Protobuf)ExpositionFormatsTest, the question is whether these changes should or must be configurable like in the ExpositionFormats? Should there be a feature flag to enable enriching the createdTimestamp?

cmaune avatar Aug 12 '25 21:08 cmaune

Should there be a feature flag to enable enriching the createdTimestamp?

no, for protobuf, it can always be included

zeitlinger avatar Aug 14 '25 10:08 zeitlinger

Sorry for the delay. PR is opened @zeitlinger

cmaune avatar Aug 22 '25 16:08 cmaune