Skip to content

Stabilize Prometheus Native Histogram -> OTLP (Exponential) Histogram#4898

Open
krajorama wants to merge 1 commit intoopen-telemetry:mainfrom
krajorama:krajo/nh-prom-to-otel
Open

Stabilize Prometheus Native Histogram -> OTLP (Exponential) Histogram#4898
krajorama wants to merge 1 commit intoopen-telemetry:mainfrom
krajorama:krajo/nh-prom-to-otel

Conversation

@krajorama
Copy link
Member

Fixes #4748

Changes

Enacted from #4748 (comment)

  • The counter reset header is not mentioned -added
  • Stale NaN is not defined in the document - added link to code where the bit representation can be found
  • Conversion of spans and counts is a bit hand-wavy, I understand why you'd want to link to something - added precise wording and link
  • Off by one of the offset is mentioned, but it doesn't say if it's -1 or +1 - precise now with explanation
  • NHCB (-53) schema is missing indeed - added
  • Prometheus has renamed the Created timestamp to Start timestamp to be more aligned
  • I'm not sure if the overflow buckets of native histograms are handled or how they work in OTel. Where do you count - values equal to +-Inf or values outside float64 ? - these were indeed not handled, specified now

Additionally added notes on Count and Sum for special value cases. Note that the OTel metric data model does not have "MUST" requirements on the special values or if the overall Count must be equal to the sum of all buckets.

For non-trivial changes, follow the change proposal process.

  • Related issues #
  • Related OTEP(s) #
  • Links to the prototypes (when adding or changing features)
  • CHANGELOG.md file updated for non-trivial changes
    • For trivial changes, include [chore] in the PR title to skip the changelog check
  • Spec compliance matrix updated if necessary

@krajorama krajorama requested review from a team as code owners February 23, 2026 11:01
Fixes: open-telemetry#4748

See task list in the issues comments.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Comment on lines +187 to +189
are spans, otherwise left at 0. Note that Prometheus Native Histogram
buckets are indexed by upper boundary while Exponential Histograms are
indexed by lower boundary, hence the minus one.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe rephrase this as "The minus one is because Prometheus Native ..."

- `Sum` is converted to the Exponential Histogram `Sum`.
[Stale NaN value](https://github.com/prometheus/prometheus/blob/main/model/value/value.go).
Otherwise,
- `Count` is converted to Exponential Histogram `Count`. Note that the `Count`
Copy link
Contributor

Choose a reason for hiding this comment

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

From https://github.com/open-telemetry/opentelemetry-proto/blob/1e725b853bc8f6b46ee62e8232e4c83017b9536f/opentelemetry/proto/metrics/v1/metrics.proto#L544:

// The number of values in the population. Must be
// non-negative. This value must be equal to the sum of the "bucket_counts"
// values in the positive and negative Buckets plus the "zero_count" field.
fixed64 count = 4;

Not sure if we are allowed to have it be greater than the sum of other fields... Maybe we need to actually sum up all of the bucket counts instead of using the count directly?

use.
- The Native Histogram may contain overflow buckets. If converted to
an Exponential Histogram bucket, the overflow bucket would map to values
outside the IEEE float range. The Native Histogram SHOULD be dropped in
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why the recommendation is to drop the whole histogram. We should definitely always drop the overflow bucket, though.

- `StartTimeUnixNano` is set to the `Start Timestamp` timestamp, if available.
- `AggregationTemporality` is set to `cumulative`.

A Native histogram with custom buckets (NHCB) schema (i.e. schema -53) and which
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still nervous about "leaking" the NHCB concept outside of the prometheus server / prometheus receiver. E.g. SDK bridges from Prom -> OTel would never need to implement this... WDYT about leaving this out of the specification and considering it implicit in the (classic) histogram section.

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.

[prometheus] Stabilize Prometheus -> OTLP: Native Histograms

3 participants