Skip to content

Commit 8b61d96

Browse files
authored
Updated during WG sync
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
1 parent f5743f7 commit 8b61d96

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

docs/tutorials/open_metrics_2_0_migration.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
---
2-
title: OpenMetrics 2.0 Migration Guide for Exposers
2+
title: OpenMetrics 2.0 Migration Guide for Client Libraries
33
sort_rank: 6
44
---
55

6-
This guide covers the changes from OpenMetrics 1.0 to OpenMetrics 2.0 that affect exposer implementations. Sections are organized by implementation order so you can implement changes incrementally, starting with version negotiation and working through metric types, syntax, and metadata. This guide may contain errors, and in any case where this document disagrees with the spec document, the spec document is the authoritative source of truth.
6+
This guide covers the changes from OpenMetrics (OM) 1.0 to OpenMetrics 2.0 that affect client library (i.e. exposers) implementations. Sections are organized so you can implement changes incrementally, starting with version negotiation and working through metric types, syntax, and metadata. This guide may contain errors, and in any case where this document disagrees with the spec document, **the spec document is the authoritative source of truth**.
77

8-
> **Draft specification.** OpenMetrics 2.0 is currently version 2.0.0-rc0 and is not yet finalized. Details in this guide may change before the spec reaches 2.0.0. Track progress at the [OpenMetrics 2.0 work group issue](https://github.com/prometheus/OpenMetrics/issues/276).
8+
> WARNING: OpenMetrics 2.0 is currently experimental (release candidate versions), so some details might change. Track progress at the [OpenMetrics 2.0 work group issue](https://github.com/prometheus/OpenMetrics/issues/276).
99
10-
This guide covers the changes most relevant to exposer authors. For the complete specification including ABNF grammar, conformance requirements, and ingester rules, see the full [OpenMetrics 2.0 specification](../specs/om/open_metrics_spec_2_0.md). If you find errors or have questions, file an issue on the [OpenMetrics repository](https://github.com/prometheus/OpenMetrics).
10+
This guide covers the changes most relevant to client library / exposer authors. For the complete specification including ABNF grammar, conformance requirements, and ingester rules, see the full [OpenMetrics 2.0 specification](../specs/om/open_metrics_spec_2_0.md). If you find errors or have questions, file an issue on the [OpenMetrics repository](https://github.com/prometheus/OpenMetrics).
1111

1212
## How to use this guide
1313

14-
Each section below guides implementers through the change:
14+
Each section below guides implementers through the changes. We use a **Breaking** or **Non-breaking** label. A change is **Breaking** if a line that was valid in OM 1.0 is now invalid in OM 2.0. A **Non-breaking** change adds new syntax or relaxes restrictions without invalidating any existing valid line.
1515

16-
- A **Breaking** or **Non-breaking** label. A change is **Breaking** if a line that was valid in OM 1.0 is now invalid in OM 2.0. A **Non-breaking** change adds new syntax or relaxes restrictions without invalidating any existing valid line.
17-
- A brief refresher of the 1.0 behavior and the 2.0 change.
18-
- Before/after code blocks labeled "OM 1.0:" and "OM 2.0:" showing the difference.
19-
20-
There is also a reference to the relevant section of the specification if more detail is required.
16+
There are also references to the relevant section of the specification if more detail is required.
2117

2218
## Quick Reference
2319

24-
OpenMetrics 2.0 contains many changes. Some of those changes are a loosening of previously-strict requirements, like the way metric names are constructed or character limits. Most of these changes are in service of allowing OpenTelemetry metric data to be encoded in OpenMetrics without violating the specification. Other changes introduce new syntaxes, mostly focused on allowing metric data to be encoded into a single line rather than requiring multiple lines to describe one cohesive piece of information. Lastly, some changes add new features and data types, like Native Histograms.
20+
OpenMetrics 2.0 contains many changes. Some of those changes are a loosening of previously-strict requirements, like the way metric names are constructed or character limits. Some of these changes are in service of allowing OpenTelemetry metric data to be encoded in OpenMetrics without violating the specification. Other changes improve scraper (e.g. Prometheus) efficiency and reliablity on various cases. Changes introduce new syntaxes, mostly focused on allowing metric data to be encoded into a single line rather than requiring multiple lines to describe one cohesive piece of information. Lastly, some changes add new features and data types, like Native Histograms.
2521

2622
| Change | 1.0 | 2.0 | Breaking? |
2723
| -------------------------------------------------------------------------------- | ---------------------------------------- | -------------------------------------------------- | --------- |
@@ -67,29 +63,31 @@ application/openmetrics-text; version=2.0.0; charset=utf-8
6763

6864
### Negotiation defaults
6965

70-
Exposers MUST default to the oldest version of the standard (1.0.0) when no specific version is requested. This applies to both pull and push models:
71-
72-
- **Pull-based (HTTP):** Use standard HTTP content-type negotiation. If the scraper does not request version 2.0.0, respond with 1.0.0.
73-
- **Push-based:** Use version 1.0.0 unless the ingestor explicitly requests a newer version.
66+
Exposers MUST default to the oldest version of the standard (1.0.0) when no specific version is requested. Use standard HTTP content-type negotiation. If the scraper does not request version 2.0.0, respond with 1.0.0.
7467

7568
This means your exposer should continue serving 1.0 format by default and only switch to 2.0 when the consumer asks for it.
7669

7770
### Protobuf format removed
7871

79-
OM 2.0 no longer specifies an official protobuf format. You may continue to support the protobuf format for 1.0, but 2.0 does not contain a new or updated protobuf format. For the Prometheus protobuf wire format and other available formats, see the [exposition formats documentation](https://prometheus.io/docs/instrumenting/exposition_formats).
72+
OM 2.0 no longer specifies an official protobuf format. You may continue to support the protobuf format for 1.0 (we d, but 2.0 does not contain a new or updated protobuf format.
73+
74+
The Prometheus protobuf wire format is still important and maintain, see the [exposition formats documentation](https://prometheus.io/docs/instrumenting/exposition_formats).
8075

8176
See: [Protocol Negotiation](../specs/om/open_metrics_spec_2_0.md#protocol-negotiation) in the OM 2.0 spec.
8277

8378
## Naming Changes
8479

8580
OM 2.0 tightens the relationship between MetricFamily names and Metric Names, and changes the suffix rules for counters and info metrics. In OM 1.0, parsers implicitly stripped known suffixes to map sample names back to their MetricFamily. In OM 2.0, this implicit stripping is gone: the MetricFamily name must exactly match every Metric's Name.
8681

82+
Generally, the mandatory unit and `_total` suffix is also now recommended, but not required.
83+
8784
### Specification Terminology Changes
8885

89-
**Non-breaking**: Does not affect exposition format, only the terms used in the spec.
86+
**Non-breaking**: Does not affect exposition format, only the terms used in the spec. It's useful to understand this change for easier use of the OM 2.0 spec.
9087

9188
OM 2.0 restructures the data model hierarchy. In OM 2.0, MetricPoint is removed and Sample becomes a first-class data model object:
9289

90+
<!-- TODO: add diagram -->
9391
**OM 1.0:** MetricSet → MetricFamily → Metric → MetricPoint → Sample (text format)
9492
**OM 2.0:** MetricSet → MetricFamily → Metric → Sample (with Number or CompositeValue)
9593

@@ -108,6 +106,7 @@ OM 2.0 restructures the data model hierarchy. In OM 2.0, MetricPoint is removed
108106

109107
In OM 1.0, a counter's TYPE line used a base name (e.g. `http_requests`) while its samples carried the `_total` suffix (e.g. `http_requests_total`). The parser knew to strip `_total` when matching samples back to their MetricFamily, so the MetricFamily name and sample Metric Name could differ.
110108

109+
<!--change to "must" unless we quote spec-->
111110
In OM 2.0, the MetricFamily name MUST exactly match every Metric's Name. There is no implicit suffix stripping. For counters, this means the TYPE line must include `_total` if the samples use it.
112111

113112
OM 1.0:
@@ -316,7 +315,7 @@ See: [Counter](../specs/om/open_metrics_spec_2_0.md#counter) and [Histogram with
316315

317316
## CompositeValues
318317

319-
**Breaking**: Traditional multiline complex types are no longer allowed.
318+
**Breaking**: Traditional multiline complex types are no longer allowed (except StateSet).
320319

321320
In OM 1.0, complex metric types (histograms, summaries, gaugehistograms) were represented as multiple expanded sample lines — one line per bucket, one for count, one for sum. In OM 2.0, these become a single sample line whose value is a CompositeValue: a structured `{key:value,...}` block containing all the fields at once.
322321

0 commit comments

Comments
 (0)