Skip to content

Update OpenTelemetry Exponential Histogram to Prometheus Native Histogram translation#5125

Open
krajorama wants to merge 10 commits into
open-telemetry:mainfrom
krajorama:stabilize-exp-histogram-translation
Open

Update OpenTelemetry Exponential Histogram to Prometheus Native Histogram translation#5125
krajorama wants to merge 10 commits into
open-telemetry:mainfrom
krajorama:stabilize-exp-histogram-translation

Conversation

@krajorama

@krajorama krajorama commented Jun 1, 2026

Copy link
Copy Markdown
Member

Related to #4922

Changes

Update the OTLP Exponential Histogram to Prometheus Native Histogram (standard exponential schema) conversion section and restructure the bullets to mirror the Histograms section established in #5091.

Notable substantive changes alongside the status flip:

  • Split NoRecordedValue handling into explicit true / false branches, matching the NHCB structure in Stabilize Histogram to Prometheus translation and specify NHCB conversion #5091.
  • Fix the NoRecordedValue == true handling: the Native Histogram Count is a uint64, so it MUST be set to 0 (not the Stale NaN value). ZeroCount, PositiveSpans, PositiveDeltas, NegativeSpans, and NegativeDeltas MUST be left empty. This is the follow-up flagged in Stabilize Histogram to Prometheus translation and specify NHCB conversion #5091 (comment) .
  • Set the Native Histogram ResetHint (or CounterResetHint) to UNKNOWN. OpenTelemetry does not carry an explicit reset flag, so UNKNOWN lets Prometheus auto-detect resets from the values and avoids any semantic divergence with OpenTelemetry's reset model.
  • Add StartTimeUnixNano → Prometheus StartTime mapping, consistent with the (now Stable) Histograms section. The previous text said StartTimeUnixNano was "not used", which contradicted the symmetric reverse-direction conversion.
  • Note that fields not explicitly referenced are left at their zero value (mirroring NHCB).
  • Relax the delta-temporality rule from "MUST be dropped" to "MAY be aggregated to a cumulative aggregation temporality, or MUST be dropped", matching the (now Stable) Histograms section.
  • Expand the dense-to-sparse bucket conversion bullet with the same level of detail as Stabilize Histogram to Prometheus translation and specify NHCB conversion #5091's NHCB section: which counts are converted, delta-encoding semantics, span Offset/Length semantics (absolute for the first span, relative for subsequent spans), and a worked example. An explicit formula maps an Exponential Histogram bucket array position to a Native Histogram bucket index (Offset + i + 1), since the indexing convention differs by one between the two formats.

The detailed bucket-conversion explanation is open for discussion — see the inline review comment showing the shorter alternative, and #5091 for the equivalent NHCB wording.

Coded with Claude Opus 4.7.

…stogram translation

Mark the OTLP Exponential Histogram to Prometheus Native Histogram (standard
exponential schema) conversion section as Stable. Restructure the bullets to
mirror the Histograms section established in open-telemetry#5091, splitting the
NoRecordedValue handling into explicit true/false branches.

Fix the NoRecordedValue handling: the Native Histogram Count is a uint64 and
MUST be set to zero (not the Stale NaN value) on staleness, with
ZeroCount/PositiveSpans/PositiveDeltas/NegativeSpans/NegativeDeltas left
empty. Set the Native Histogram ResetHint to UNKNOWN since OpenTelemetry
does not carry an explicit reset flag. Add StartTimeUnixNano handling
consistent with the Histograms section, and note that fields not explicitly
referenced are left at their zero value. Relax the delta-temporality rule
from "MUST be dropped" to "MAY be aggregated to cumulative or MUST be
dropped", matching the (now Stable) Histograms section.

Fixes open-telemetry#4922

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama
krajorama requested review from a team as code owners June 1, 2026 09:57
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 1, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

Comment thread specification/compatibility/prometheus_and_openmetrics.md
@krajorama
krajorama force-pushed the stabilize-exp-histogram-translation branch from a0d967f to e9346fe Compare June 1, 2026 10:11
Mirror the detailed explanation added for the OpenTelemetry Histogram to
Prometheus NHCB conversion in open-telemetry#5091: split the sparse-layout conversion
into separate bullets covering which counts are converted, delta encoding,
span Offset/Length semantics, and a worked example. Provide an explicit
formula (`Offset + i + 1`) for mapping an Exponential Histogram bucket
array position to a Native Histogram bucket index, since the indexing
convention differs by one between the two formats.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama
krajorama force-pushed the stabilize-exp-histogram-translation branch from e9346fe to 2923849 Compare June 1, 2026 10:14
@krajorama

Copy link
Copy Markdown
Member Author

The markdown-link-check fails on main as well since #4932 cc @christos68k

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes the specification for translating OTLP Exponential Histogram datapoints into Prometheus Native Histograms (standard exponential schema) in the Prometheus/OpenMetrics compatibility document, aligning structure and semantics with the (recently stabilized) histogram translation guidance.

Changes:

  • Mark OTLP Exponential Histogram → Prometheus Native Histogram translation as Stable and reorganize conversion bullets to a more explicit, symmetric structure.
  • Clarify NoRecordedValue handling (explicit true/false branches), reset-hint behavior (UNKNOWN), and add StartTimeUnixNano → Prometheus StartTime mapping.
  • Expand the dense-to-sparse bucket conversion description with span/delta semantics and a worked example; update the changelog accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
specification/compatibility/prometheus_and_openmetrics.md Marks Exponential Histogram translation as Stable and refines/expands the normative conversion rules to Prometheus Native Histograms.
CHANGELOG.md Adds an Unreleased changelog entry noting stabilization of the Exponential Histogram → Native Histogram translation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specification/compatibility/prometheus_and_openmetrics.md Outdated
Comment thread specification/compatibility/prometheus_and_openmetrics.md Outdated
Comment on lines +531 to +534
- The `ResetHint` (or `CounterResetHint`) in the Native Histogram MUST be set
to `UNKNOWN`. OpenTelemetry does not carry an explicit reset flag, so
`UNKNOWN` lets Prometheus auto-detect resets from the values and avoids any
semantic divergence with OpenTelemetry's reset model.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as #5091 (comment).

I believe OTel has carries explicit reset information, so we can probably do better here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolving it because this does not appear to be addressed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the PR getting merged, looks like we're moving forward with MUST. Could you elaborate on what is not addressed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetry does not carry an explicit reset flag

@jmacd argued here that OTel carries implicit reset information: #5091 (comment)

I didn't see an obvious resolution to that conversation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had strong enough arguments against using that implicit reset information. @jmacd wdyt?

@jmacd jmacd Jun 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should declare a bug in the specification, detailed by @krajorama here: #5091 (comment)

That is to say, I've read the list of reset-flags in the document https://prometheus.io/docs/specs/native_histograms/#counter-reset-considerations and I think we can write well-defined rules for generating them all; what we write in the data model document is not the same as what we write in an SDK specification. The SDK knows more in general than a Collector does in this situation, so I would say the SDK has better options than to set UNKNOWN, at least.

@krajorama krajorama Jul 8, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting UNKNOWN is never a bug from Prometheus point of view. If you think we're going to miss some resets, then that could be considered a bug from OTEL point of view.

Prometheus will honor if you set RESET hint (or GAUGE hint - it's a different discussion for delta temporality). There is a danger that if you abuse the RESET hint, it will generate a lot of overhead in Prometheus without benefit - because storage units (chunks) are cut on every RESET hint.

Prometheus will not honor NOTRESET hint, because it depends on it being 100% accurate, so it will validate the input anyway.

what we write in the data model document is not the same as what we write in an SDK specification

I'm not sure I follow, shouldn't the SDK spec follow the data model?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to deal with this in a separate issue, can we merge this PR? Note: this PR does not stabilize this part of the spec anymore, that was removed from the PR and deferred. @jmacd

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And finally: it would be nice to hash these out in our upcoming OTEL Prometheus WG meeting on the 17th of July. See the OTEL calendar.

krajorama and others added 2 commits June 8, 2026 09:55
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@krajorama

Copy link
Copy Markdown
Member Author

I think this is ready to merge. Markdown fail due to github.com gateway timeout.

@cijothomas cijothomas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for driving this! One process question: this PR combines the status flip with actual wording changes. Could you split into (1) the wording changes while still Experimental, then (2) a clean flip-to-Stable PR that only changes the status?

Not objecting to the stabilization or the contents - just trying to keep stabilization PRs scoped to "flip the status, nothing more" so reviewers don't have to evaluate both at once.

…gram-translation

Also undo stabilization part.


Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama
krajorama requested a review from a team as a code owner June 11, 2026 09:02
@krajorama krajorama changed the title Stabilize OpenTelemetry Exponential Histogram to Prometheus Native Histogram translation Update OpenTelemetry Exponential Histogram to Prometheus Native Histogram translation Jun 11, 2026
@krajorama

Copy link
Copy Markdown
Member Author

Thanks for driving this! One process question: this PR combines the status flip with actual wording changes. Could you split into (1) the wording changes while still Experimental, then (2) a clean flip-to-Stable PR that only changes the status?

Not objecting to the stabilization or the contents - just trying to keep stabilization PRs scoped to "flip the status, nothing more" so reviewers don't have to evaluate both at once.

I've updated the PR to not do the stabilization , just update the text.

@cijothomas
cijothomas dismissed their stale review June 12, 2026 17:13

Concern addressed by removing stabilization status change from this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants