@@ -160,7 +160,7 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
160160 }
161161
162162 var contentType expfmt.Format
163- if opts .EnableOpenMetrics {
163+ if opts .EnableOpenMetrics || opts . OpenMetricsOptions . EnableOpenMetrics {
164164 contentType = expfmt .NegotiateIncludingOpenMetrics (req .Header )
165165 } else {
166166 contentType = expfmt .Negotiate (req .Header )
@@ -181,7 +181,7 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
181181 }
182182
183183 var enc expfmt.Encoder
184- if opts .EnableOpenMetricsCreatedMetrics {
184+ if opts .OpenMetricsOptions . EnableOpenMetricsCreatedMetrics {
185185 enc = expfmt .NewEncoder (w , contentType , expfmt .WithCreatedLines ())
186186 } else {
187187 enc = expfmt .NewEncoder (w , contentType )
@@ -366,6 +366,32 @@ type HandlerOpts struct {
366366 // away). Until the implementation is improved, it is recommended to
367367 // implement a separate timeout in potentially slow Collectors.
368368 Timeout time.Duration
369+ // If true, the experimental OpenMetrics encoding is added to the
370+ // possible options during content negotiation. Note that Prometheus
371+ // 2.5.0+ will negotiate OpenMetrics as first priority. OpenMetrics is
372+ // the only way to transmit exemplars. However, the move to OpenMetrics
373+ // is not completely transparent. Most notably, the values of "quantile"
374+ // labels of Summaries and "le" labels of Histograms are formatted with
375+ // a trailing ".0" if they would otherwise look like integer numbers
376+ // (which changes the identity of the resulting series on the Prometheus
377+ // server).
378+ //
379+ // Deprecated: Use OpenMetricsOptions.EnableOpenMetrics instead.
380+ EnableOpenMetrics bool
381+ // OpenMetricsOptions holds settings for the experimental OpenMetrics encoding.
382+ // It can be used to enable OpenMetrics encoding and for setting extra options.
383+ OpenMetricsOptions OpenMetricsOptions
384+ // ProcessStartTime allows setting process start timevalue that will be exposed
385+ // with "Process-Start-Time-Unix" response header along with the metrics
386+ // payload. This allow callers to have efficient transformations to cumulative
387+ // counters (e.g. OpenTelemetry) or generally _created timestamp estimation per
388+ // scrape target.
389+ // NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus
390+ // exposition format.
391+ ProcessStartTime time.Time
392+ }
393+
394+ type OpenMetricsOptions struct {
369395 // If true, the experimental OpenMetrics encoding is added to the
370396 // possible options during content negotiation. Note that Prometheus
371397 // 2.5.0+ will negotiate OpenMetrics as first priority. OpenMetrics is
@@ -391,14 +417,6 @@ type HandlerOpts struct {
391417 // _created lines will result in increased cardinality and no improvements
392418 // in reset detection.
393419 EnableOpenMetricsCreatedMetrics bool
394- // ProcessStartTime allows setting process start timevalue that will be exposed
395- // with "Process-Start-Time-Unix" response header along with the metrics
396- // payload. This allow callers to have efficient transformations to cumulative
397- // counters (e.g. OpenTelemetry) or generally _created timestamp estimation per
398- // scrape target.
399- // NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus
400- // exposition format.
401- ProcessStartTime time.Time
402420}
403421
404422// gzipAccepted returns whether the client will accept gzip-encoded content.
0 commit comments