Skip to content

Conversation

@thomasstauffer666
Copy link

@thomasstauffer666 thomasstauffer666 commented Nov 22, 2025

Fixes #2111 and implements exponential histogram support in opentelemetry-stdout.

Design discussion issue (if applicable) #

Changes

Please provide a brief description of the changes here.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 22, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@scottgerring scottgerring self-requested a review November 22, 2025 15:33
@codecov
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

❌ Patch coverage is 2.73973% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.5%. Comparing base (df412fe) to head (4954e3d).

Files with missing lines Patch % Lines
opentelemetry-stdout/src/metrics/exporter.rs 0.0% 71 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3259     +/-   ##
=======================================
- Coverage   80.8%   80.5%   -0.3%     
=======================================
  Files        129     129             
  Lines      23203   23272     +69     
=======================================
  Hits       18750   18750             
- Misses      4453    4522     +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scottgerring
Copy link
Member

@thomasstauffer666 let us know when this is ready for review!

@scottgerring scottgerring changed the title Improve support for exponential histogram feat: Improve support for exponential histogram Nov 22, 2025
@scottgerring scottgerring self-assigned this Nov 22, 2025
@thomasstauffer666 thomasstauffer666 force-pushed the main branch 2 times, most recently from 7bfc771 to 2cd0f32 Compare November 22, 2025 17:29
@thomasstauffer666
Copy link
Author

@scottgerring would be ready for review

codecov correctly reports that nothing I added to stdout is tested. AFAIK rust has no official way to unit test functions which use stdout. Possibilites I see:

  • Leave it as is
  • Use a module like gag which only works on unix
  • Rewrite opentelemetry-stdout to not directly use println! instead using a writer (or something else) which by default uses stdout, but at least for testing could be redirected, but this would be another PR then

@scottgerring
Copy link
Member

hey @thomasstauffer666 great - cheers! I'll check it out tomorrow 💪

Apropos the stdout coverage; we try and be pragmatic with coverage, and my initial thought is that this is a case where we don't need to go wild chasing it, but I will form proper opinions shortly.

@scottgerring scottgerring marked this pull request as ready for review November 25, 2025 08:27
@scottgerring scottgerring requested a review from a team as a code owner November 25, 2025 08:27
Copy link
Member

@scottgerring scottgerring left a comment

Choose a reason for hiding this comment

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

Hey @thomasstauffer666 thanks for the PR! Couple of minor notes inline

p.s. if you would like to chat about this or other otel-rust stuff, you can join us in #opentelemetry-rust in the CNCF slack 🤝

}
};

// for example 3
Copy link
Member

Choose a reason for hiding this comment

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

It would be cool to be a bit more descriptive with the examples; "This is an exponential histogram, this is great for bucketed data that is exponential in nature" or something, I reckon. The example text on the others above is not so detailed, but this feels like it is introducing nuance, in that we have two examples of histograms now, and its not going to be obvious to all folks which to use when.

Likewise on the aggregation front down around L40-43, some brief comments on the tunables would be great; ultimately we want this all to feel overly descriptive / obvious, so there's less room for folks to waste time guessing at things!

if *max_scale > EXPO_MAX_SCALE {
return Err(MetricError::Config(format!(
"aggregation: exponential histogram: max scale ({max_scale}) is greater than 20",
"aggregation: exponential histogram: max scale ({max_scale}) is greater than {}", EXPO_MAX_SCALE
Copy link
Member

Choose a reason for hiding this comment

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

nice catch!

Comment on lines 321 to 326
let from = -base.powf(i as f64 + negative_offset as f64);
let to = -base.powf(i as f64 + negative_offset as f64 + 1.0f64);
println!(
"\t\t\t\t -> Bucket {} (> {:.3} to <= {:.3}) : {}",
i, from, to, count
);
Copy link
Member

Choose a reason for hiding this comment

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

I think this gets the labels backwards for negative i - such that from > to

print_hist_data_points(histogram.data_points());
}

fn print_exponential_histogram<T: Debug + Copy>(histogram: &ExponentialHistogram<T>) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you update opentelemetry-stdout/CHANGELOG.md with a brief note about this?

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.

[Feature]: Provide an example of exponential histogram.

2 participants