Skip to content

Commit

Permalink
Prometheus compatibility: represent Prometheus Info, StateSet and Unk…
Browse files Browse the repository at this point in the history
…nown-typed metrics in OTLP
  • Loading branch information
dashpole committed Feb 7, 2024
1 parent fa5eca7 commit b22dd04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ release.

### Compatibility

- Prometheus: represent Prometheus Info, StateSet and Unknown-typed metrics in OTLP.
([#3868](https://github.com/open-telemetry/opentelemetry-specification/pull/3868))

### SDK Configuration

- Add file configuration section to spec compliance matrix.
Expand Down
13 changes: 12 additions & 1 deletion specification/compatibility/prometheus_and_openmetrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ The [OpenMetrics TYPE metadata](https://github.com/OpenObservability/OpenMetrics
if present, MUST be used to determine the OTLP data type, and dictates
type-specific conversion rules listed below. Metric families without type
metadata follow rules for [unknown-typed](#unknown-typed) metrics below.
The TYPE metadata MUST also be added to the OTLP [metric.metadata](https://github.com/open-telemetry/opentelemetry-proto/blob/c451441d7b73f702d1647574c730daf7786f188c/opentelemetry/proto/metrics/v1/metrics.proto#L199)
under the `prometheus.type` key (e.g. `prometheus.type="unknown"`).

### Counters

Expand Down Expand Up @@ -269,13 +271,22 @@ Prometheus exporters SHOULD provide a configuration option to disable the

### Gauges

An [OpenTelemetry Gauge](../metrics/data-model.md#gauge) MUST be converted to a Prometheus Gauge.
An [OpenTelemetry Gauge](../metrics/data-model.md#gauge) MUST be converted to
a Prometheus Unknown-typed metric if the `prometheus.type` key of
[metric.metadata](https://github.com/open-telemetry/opentelemetry-proto/blob/c451441d7b73f702d1647574c730daf7786f188c/opentelemetry/proto/metrics/v1/metrics.proto#L199)
is `unknown`. Otherwise, it MUST be converted to a Prometheus Gauge.

### Sums

[OpenTelemetry Sums](../metrics/data-model.md#sums) follows this logic:

- If the aggregation temporality is cumulative and the sum is monotonic, it MUST be converted to a Prometheus Counter.
- If the aggregation temporality is cumulative and the sum is non-monotonic and the `prometheus.type` key of
[metric.metadata](https://github.com/open-telemetry/opentelemetry-proto/blob/c451441d7b73f702d1647574c730daf7786f188c/opentelemetry/proto/metrics/v1/metrics.proto#L199)
is `info`, it MUST be converted to an OpenMetrics Info metric.
- If the aggregation temporality is cumulative and the sum is non-monotonic and the `prometheus.type` key of
[metric.metadata](https://github.com/open-telemetry/opentelemetry-proto/blob/c451441d7b73f702d1647574c730daf7786f188c/opentelemetry/proto/metrics/v1/metrics.proto#L199)
is `stateset`, it MUST be converted to an OpenMetrics StateSet metric.
- If the aggregation temporality is cumulative and the sum is non-monotonic, it MUST be converted to a Prometheus Gauge.
- If the aggregation temporality is delta and the sum is monotonic, it SHOULD be converted to a cumulative temporality and become a Prometheus Counter. The following behaviors are expected:
- The new data point type must be the same as the accumulated data point type.
Expand Down

0 comments on commit b22dd04

Please sign in to comment.