Skip to content

Prometheus exponential histogram validate scale range #6779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dashpole opened this issue May 15, 2025 · 1 comment · May be fixed by #6822
Open

Prometheus exponential histogram validate scale range #6779

dashpole opened this issue May 15, 2025 · 1 comment · May be fixed by #6822
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@dashpole
Copy link
Contributor

I'm doing a late review of #6421, and am comparing it to the implementation here: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/9cb3ada6449ae195aa904f82f1ac972ff401974b/pkg/translator/prometheusremotewrite/histograms.go#L50

We need to ensure the scale is valid for Prometheus (-4 to 8), and scale down if it is greater than 8, or reject.

cc @GiedriusS

@MrAlias MrAlias added help wanted Extra attention is needed good first issue Good for newcomers labels May 22, 2025
@MrAlias MrAlias added this to the v1.37.0 milestone May 22, 2025
@highlyavailable
Copy link
Contributor

@MrAlias could I pick this up?

highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 24, 2025
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 24, 2025
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 24, 2025
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 30, 2025
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 30, 2025
… compatibility

Implements scale validation and bucket re-aggregation for exponential histograms to ensure compatibility with Prometheus native histograms, which support scales in the range [-4, 8].

  - Reject scales below -4 with error logging (skip data point)
  - Downscale histograms with scale > 8 by re-aggregating buckets
  - Add downscaleExponentialBucket function that merges buckets when downscaling
  - Fix overflow/underflow checks to handle negative bucket offsets correctly
  - Add comprehensive tests for scale validation and bucket downscaling

Fixes open-telemetry#6779
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 30, 2025
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 30, 2025
… compatibility

Implements scale validation and bucket re-aggregation for exponential histograms to ensure compatibility with Prometheus native histograms, which support scales in the range [-4, 8].

  - Reject scales below -4 with error logging (skip data point)
  - Downscale histograms with scale > 8 by re-aggregating buckets
  - Add downscaleExponentialBucket function that merges buckets when downscaling
  - Fix overflow/underflow checks to handle negative bucket offsets correctly
  - Add comprehensive tests for scale validation and bucket downscaling

Fixes open-telemetry#6779
highlyavailable added a commit to highlyavailable/opentelemetry-go that referenced this issue May 30, 2025
Fixes open-telemetry#6779

Add scale validation for Prometheus exponential histograms to ensure
compatibility with Prometheus native histogram format.

Changes:
- Validate scale is within Prometheus supported range [-4, 8]
- Reject scales below -4 (log error and skip data point)
- Downscale histograms with scale > 8 by re-aggregating buckets
- Add comprehensive test coverage for scale validation and downscaling
- Implement downscaling logic based on OpenTelemetry Collector Contrib

The downscaling implementation merges buckets using bit-shifting to
maintain accuracy while conforming to Prometheus limitations.
@pellared pellared modified the milestones: v1.37.0, Subsequent v1.37.0 Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment