Title: Experimental OpenMetrics 2.0 support · Issue #1912 · prometheus/client_java · GitHub
Open Graph Title: Experimental OpenMetrics 2.0 support · Issue #1912 · prometheus/client_java
X Title: Experimental OpenMetrics 2.0 support · Issue #1912 · prometheus/client_java
Description: The OpenMetrics 2.0 spec is nearing completion. We should start implementing experimental support to validate the design and provide early feedback to the spec authors. All features are behind opt-in flags (off by default) so there's no ...
Open Graph Description: The OpenMetrics 2.0 spec is nearing completion. We should start implementing experimental support to validate the design and provide early feedback to the spec authors. All features are behind opt-...
X Description: The OpenMetrics 2.0 spec is nearing completion. We should start implementing experimental support to validate the design and provide early feedback to the spec authors. All features are behind opt-...
Opengraph URL: https://github.com/prometheus/client_java/issues/1912
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Experimental OpenMetrics 2.0 support","articleBody":"The [OpenMetrics 2.0 spec](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md) is nearing completion. We should start implementing experimental support to validate the design and provide early feedback to the spec authors.\n\nAll features are behind opt-in flags (off by default) so there's no risk to existing users. The spec is still in draft, so the API is explicitly experimental and subject to change.\n\n## Status\n\nImplemented:\n\n- PR 1: Flag infrastructure (#1939) ✅\n- PR 2: OM2 writer skeleton (#1951) ✅\n- PR 3: enabled flag (#1953) ✅\n- PR 4a: Core + OM1 writers (#1955) ✅\n- PR 4b: OTel preserve_names (#1956) ✅\n- PR 4c: OM2 writer no-suffix (#1957) ✅\n- PR 5: content negotiation (#1986) ✅\n- PR 6: compositeValues + exemplarCompliance (#1991, closes #1989) ✅\n- PR 7: nativeHistograms (#2042, closes #1990) ✅\n\nRemaining:\n\n- PR 8: Documentation (#1954)\n\n## Flag design\n\nTop-level gate + individual feature flags. The top-level gate (`enableOpenMetrics2()`)\nsets `enabled=true` implicitly and enables the sub-flags. Each sub-flag\nindependently controls one OM2 feature.\n\n**Java builder API:**\n\n```java\nPrometheusProperties config = PrometheusProperties.builder()\n .enableOpenMetrics2(om2 -> om2\n .contentNegotiation(true) // version=2.0.0 content type\n .compositeValues(true) // single-line histogram/summary + st@\n .exemplarCompliance(true) // mandatory timestamps, no size limit\n .nativeHistograms(true) // exponential buckets\n )\n .build();\n\n// Or enable everything at once\nPrometheusProperties config = PrometheusProperties.builder()\n .enableOpenMetrics2(om2 -> om2.enableAll())\n .build();\n```\n\n**Properties equivalent:**\n\n```properties\nio.prometheus.openmetrics2.enabled=true\nio.prometheus.openmetrics2.content_negotiation=true\nio.prometheus.openmetrics2.composite_values=true\nio.prometheus.openmetrics2.exemplar_compliance=true\nio.prometheus.openmetrics2.native_histograms=true\n```\n\nFor the minimal OM2 experience (names as provided, no suffix appending):\n\n```properties\nio.prometheus.openmetrics2.enabled=true\n```\n\n| Flag | Description | Spec reference |\n|------|-------------|----------------|\n| `enabled` | Activate the OM2 writer. Required — feature flags below have no effect without it. Set implicitly by `enableOpenMetrics2()` | — |\n| `contentNegotiation` | Gate OM2 features behind content negotiation: only apply them when the scraper requests `version=2.0.0`, and return OM1 format when the scraper requests OM1. Without this flag, OM2 features are applied even if the scraper requests OM1 | [Content Type](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#content-type) |\n| `compositeValues` | Single-line Histogram/Summary/GaugeHistogram with inline `st@` start timestamp. Also: reserved label prefix `__`, Histogram Count/Sum always present, bucket values may be float | [CompositeValue](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#compositevalue), [Overall Structure](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#overall-structure) |\n| `exemplarCompliance` | Exemplar timestamps always emitted (MUST in OM2), 128-char LabelSet hard limit removed | [Exemplar](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#exemplar) |\n| `nativeHistograms` | Exponential buckets with schema, zero threshold/count, pos/neg spans | [Native Buckets](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#native-buckets) |\n\nAll flags default to `false`.\n\n**Suffix handling** (`_total`, unit suffixes) is not an OM2 config flag — it is handled\nat scrape time by each format writer. See #1941 for the design.\n\n## PR structure\n\n```text\nPR 1: Flag infrastructure (#1939) ✅\n│\n└── PR 2: OM2 writer skeleton (#1951) ✅\n │\n ├── PR 3: enabled flag (#1953) ✅\n │ │\n │ ├── PR 4: Suffix handling:\n │ │ ├── PR 4a: Core + OM1 writers (#1955) ✅\n │ │ │ ├── PR 4b: OTel preserve_names (#1956) ✅\n │ │ │ └── PR 4c: OM2 writer no-suffix (#1957) ✅\n │ │ │\n │ │\n │ └── PR 8: Documentation (#1954)\n │\n ├── PR 5: contentNegotiation (#1986) ✅\n │\n ├── PR 6: compositeValues + exemplarCompliance (#1991, closes #1989) ✅\n │\n └── PR 7: nativeHistograms (#2042, closes #1990) ✅\n```\n\n### PR 1: Flag infrastructure (#1939) ✅\n\n- Add `enableOpenMetrics2()` to `PrometheusProperties.Builder`\n- Add `OpenMetrics2Properties` class with all flag fields (defaulting to `false`)\n- Wire up properties parsing for `io.prometheus.openmetrics2.*`\n- No behavioral changes — just the config plumbing\n\n### PR 2: OM2 writer skeleton (#1951) ✅\n\n- `OpenMetrics2TextFormatWriter` implementing `ExpositionFormatWriter`\n- Wired into `ExpositionFormats`: when OM2 is enabled, selected for OpenMetrics requests (masquerades as OM1 for testability with current Prometheus)\n- Takes `OpenMetrics2Properties` from #1939 in builder\n\n### PR 3: enabled flag (#1953) ✅\n\n- Add `io.prometheus.openmetrics2.enabled` as the explicit gate for OM2 writer selection\n- Feature flags alone no longer activate OM2 — `enabled=true` is required\n- `enableOpenMetrics2()` programmatic configurator sets `enabled=true` implicitly\n\n### PR 4a: Core + OM1 writers (#1955) ✅\n\n- Move suffix handling to scrape time — OM1 smart-appends `_total`/`_info`/unit suffixes (skips if already present)\n- `MetricMetadata` stores `originalName` and `expositionBaseName`\n- Counter/Info builders no longer strip `_total`/`_info` at creation time\n- Remove all reserved metric name suffixes from `PrometheusNaming`\n- Cross-format collision detection in `PrometheusRegistry`\n- See #1942 for design\n\n### PR 4b: OTel preserve_names (#1956) ✅\n\n- Add `preserve_names` config to `ExporterOpenTelemetryProperties`\n- Legacy path (default): strips `_total` + unit suffix\n- `preserve_names=true`: passes names through exactly as the user wrote them\n- Stacked on #1955\n\n### PR 4c: OM2 writer no-suffix (#1957) ✅\n\n- OM2 writer uses `expositionBaseName` directly — no `_total` or unit suffix appending\n- `_info` suffix enforced per OM2 spec (MUST)\n- Stacked on #1955\n\n### PR 8: Documentation (#1954)\n\n- Document OM2 preview features and configuration\n- Document OTel `preserve_names` flag\n\n### PR 5: Content negotiation (#1986) ✅\n\n- `contentNegotiation`: only return OM2 format when the scraper explicitly requests `version=2.0.0`. Without this flag, OM2 features are applied even if the scraper requests OM1\n- Spec: [Content Type](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#content-type)\n\n### PR 6: CompositeValue + start timestamp + exemplar compliance (#1991, closes #1989) ✅\n\n- `compositeValues`:\n - Histogram as single line: `foo {count:17,sum:324789.3,bucket:[0.1:8,0.25:10,0.5:11,1.0:14,+Inf:17]} 1.0 st@0.5`\n - Summary as single line: `bar {count:17,sum:324789.3,quantile:[0.95:123.7,0.99:150.0]}`\n - GaugeHistogram as single line with `gcount`/`gsum`\n - `_created` lines replaced by inline [`st@` start timestamp](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#start-timestamp)\n - `_count`, `_sum`, `_bucket` suffixed lines no longer emitted for these types\n - Reserved label prefix changed from `_` to `__`\n - Histogram/GaugeHistogram Count and Sum always present (MUST, was SHOULD for Sum)\n - Histogram bucket values may be float (SHOULD be integer, was MUST)\n - Spec: [CompositeValue](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#compositevalue), [Histogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#histogram-1), [Summary](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#summary-1)\n- `exemplarCompliance`:\n - Exemplars without timestamps are dropped so emitted OM2 exemplars always satisfy the timestamp requirement\n - 128-char LabelSet hard limit removed\n\n### PR 7: Native histograms (#2042, closes #1990) ✅\n\n- `nativeHistograms`:\n - Exponential bucket model: schema (-4 to 8), zero threshold/count, positive/negative spans and buckets\n - Text serialization: `{count:X,sum:X,schema:N,zero_threshold:F,zero_count:X,positive_spans:[...],positive_buckets:[...]}`\n - Can coexist with classic buckets on separate lines (native line MUST come first)\n - GaugeHistogram also supports native buckets (same syntax)\n - Multiple exemplars per native histogram sample\n - Spec: [Native Buckets](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#native-buckets), [Histogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec_2_0.md#histogram-1)\n- No known blockers:\n - [NHCB federation (#312)](https://github.com/prometheus/OpenMetrics/issues/312) — still open but WG decided it won't change the spec (solution is a Prometheus scraping config, not an OM change)\n - [Exemplar timestamps (#308)](https://github.com/prometheus/OpenMetrics/issues/308) — closed, resolved as MUST. We're aligned\n\n## Next steps\n\n1. Finish docs in #1954 now that the implemented OM2 surface is stable enough to describe precisely.\n2. After #1954 lands, do one pass over #1912 for any spec drift and then close the umbrella issue.\n\n## Notes\n\n- UTF-8 metric/label names are already supported (shipped in a previous release)\n- The OM2 spec is still draft — some details may change, but no known blockers for the features covered here\n- See also: [OM 2.0 upgrade guide for SDK maintainers](https://github.com/prometheus/OpenMetrics/issues/314)\n\n","author":{"url":"https://github.com/zeitlinger","@type":"Person","name":"zeitlinger"},"datePublished":"2026-02-24T16:06:06Z","url":"https://github.com/prometheus/client_java/issues/1912"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2aef34f1-6a37-8010-e9e0-591dc4af8d61 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9012:224BA2:170C20:1E8C99:6AFBB15B |
| html-safe-nonce | 98e84278cc3669ada9e4e88f1e81d16f42c6c9e95dcbb8d2c4e74c5c44692055 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDEyOjIyNEJBMjoxNzBDMjA6MUU4Qzk5OjZBRkJCMTVCIiwidmlzaXRvcl9pZCI6IjU1NTMwNzUzNjQ2ODQzNDU2OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6cd0a4b76ecd18909ca501a8f2a6b5f95b67b6f014cb845db7a2db57ba2adba1 |
| hovercard-subject-tag | issue:3984549878 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/1912/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b43fbc877eb8dab2f9a34384bf41d93fa23e9035b7224c3b9c2773398cce87fe/prometheus/client_java/issues/1912 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b43fbc877eb8dab2f9a34384bf41d93fa23e9035b7224c3b9c2773398cce87fe/prometheus/client_java/issues/1912 |
| og:image:alt | The OpenMetrics 2.0 spec is nearing completion. We should start implementing experimental support to validate the design and provide early feedback to the spec authors. All features are behind opt-... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zeitlinger |
| hostname | github.com |
| expected-hostname | github.com |
| None | e25fbd830d3e6ad0e8935c105cf4fdc70c593dffcd27bb45b790ae4fece5ea55 |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_java git https://github.com/prometheus/client_java.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 7997879 |
| octolytics-dimension-repository_nwo | prometheus/client_java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7997879 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 08c8f17f9d27054a108b8b6254e405de0151f660 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width