Skip to content
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

[processor/deltatocumulative] Exponential histogram buckets exceed maxBuckets #37416

Closed
tiit-clarifai opened this issue Jan 22, 2025 · 1 comment · Fixed by #37432
Closed
Labels
bug Something isn't working needs triage New item requiring triage processor/deltatocumulative

Comments

@tiit-clarifai
Copy link

tiit-clarifai commented Jan 22, 2025

Component(s)

processor/deltatocumulative

What happened?

Description

0.118.0 caps the number of exponential histogram buckets produced by deltatocumulative to 160 by downscaling if the number of buckets becomes too large (#33277).

However, it calculates the new scale independently for the positive and negative buckets and then uses the greater result (instead of the lesser), resulting in only one of them being capped and the other still exceeding the limit.

Steps to Reproduce

Send two positive exponential histogram data points with the same scale but offsets more than 160 apart. Do not include any negative data points.

For example (some fields omitted for brevity),

"dataPoints": [
  {
    "count": 1,
    "scale": 20,
    "positive": {
      "offset": 0,
      "bucket_counts": [1]
    }
  },
  {
    "count": 1,
    "scale": 20,
    "positive": {
      "offset": 1000,
      "bucket_counts": [1]
    }
  }
]

Expected Result

The exponential histogram is scaled to 17 to keep the number of positive buckets below 160.

Actual Result

The exponential histogram is not scaled and contains 1001 positive buckets.

Collector version

v0.118.0

Environment information

Environment

OS: macOS Sequoia 15.2

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      http:

processors:
  deltatocumulative:

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [deltatocumulative]
      exporters: [debug]

Log output

2025-01-22T16:28:58.968+0200	info	Metrics	{"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 2}
2025-01-22T16:28:58.970+0200	info	ResourceMetrics #0
Resource SchemaURL:
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope
Metric #0
Descriptor:
     -> Name: proof-of-concept
     -> Description:
     -> Unit: 1
     -> DataType: ExponentialHistogram
     -> AggregationTemporality: Cumulative
ExponentialHistogramDataPoints #0
StartTimestamp: 2025-01-22 14:28:57 +0000 UTC
Timestamp: 2025-01-22 14:28:57 +0000 UTC
Count: 1
Bucket (1.000000, 1.000001], Count: 1
ExponentialHistogramDataPoints #1
StartTimestamp: 2025-01-22 14:28:57 +0000 UTC
Timestamp: 2025-01-22 14:28:58 +0000 UTC
Count: 2
Bucket (1.000000, 1.000001], Count: 1
Bucket (1.000001, 1.000001], Count: 0
... [997 lines removed with Count: 0]
Bucket (1.000661, 1.000661], Count: 0
Bucket (1.000661, 1.000662], Count: 1

Additional context

I believe we should be taking the lesser of the limited scales for positive and negative buckets, see here: #36874 (comment)

Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@mx-psi mx-psi closed this as completed in 5d0a771 Jan 23, 2025
chengchuanpeng pushed a commit to chengchuanpeng/opentelemetry-collector-contrib that referenced this issue Jan 26, 2025
…histograms (open-telemetry#37432)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
While addressing comments a bug was added to the logic of calculating of
the desired scale and it slipped through tests.
Fix the bug (use `min` instead of `max`) and update tests to avoid
regressions in the future.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#37416 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Update tests to separately cover positive and negative buckets.

<!--Describe the documentation added.-->
#### Documentation
n/a

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New item requiring triage processor/deltatocumulative
Projects
None yet
1 participant