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

Histogram implementation cleanup #2283

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

fraillt
Copy link
Contributor

@fraillt fraillt commented Nov 7, 2024

Changes

Mostly refactoring by removing unnecessary code, with few minor improvements:

  • remove .clone() on buckets in delta collection.
  • in Histogram initialization first remove NaNs from bounds, and then get it's length.

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)

@fraillt fraillt requested a review from a team as a code owner November 7, 2024 07:03
Copy link

linux-foundation-easycla bot commented Nov 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.4%. Comparing base (52f6d92) to head (2621248).
Report is 2 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2283   +/-   ##
=====================================
  Coverage   79.4%   79.4%           
=====================================
  Files        122     122           
  Lines      20795   20783   -12     
=====================================
- Hits       16512   16506    -6     
+ Misses      4283    4277    -6     

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

let buckets_count = boundaries.len() + 1;
let mut histogram = Histogram {
pub(crate) fn new(mut bounds: Vec<f64>, record_min_max: bool, record_sum: bool) -> Self {
bounds.retain(|v| !v.is_nan());
Copy link
Member

Choose a reason for hiding this comment

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

There are only 3 ways bounds can come from:

  1. Default. - In this case, sdk provides it so we ensure its already sorted and validated.
  2. HistogramCreation API - In this case, user provides it, but while creating the instrument, sdk should validate it, and ensure its sorted/validated. If the validation fails, sdk can return the defaults or noop instrument. Opened this issue to track it: Validate user provided Histogram bounds at sdk during Instrument creation time #2286
  3. Views - In this case also, user provides it, but we should do same as 2.

I believe this method is the wrong place to validate/filter bounds as it should be taken care elsewhere.

Not a blocker for this PR, just added a comment to make sure have same understanding.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this method is the wrong place to validate/filter bounds as it should be taken care elsewhere.

💯

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM!
Left some comments but not a blocker at all.

@utpilla utpilla merged commit c322a50 into open-telemetry:main Nov 7, 2024
24 of 25 checks passed
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.

3 participants