opentelemetry-js
opentelemetry-js copied to clipboard
feat: Add Exponential Histogram
Which problem is this PR solving?
This PR includes an implementation of the Exponential Histogram for Javascript. It is heavily based on the Golang Reference Implementation.
Fixes #3324
Short description of the changes
This PR contains the entire implementation of the Exponential Histogram, but can be considered in three parts. They are:
- The mapping functions, based on the IEEE 754 floating point standard, described at length in the spec
- The ExponentialHistogramAccumulation and ExponentialHistogramAggregation
- The interfaces and code necessary to transform and export the ExponentialHistogram to OTLP
Note: I will give a walkthrough of this PR at the JS SIG meeting on Dec 21.
Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [x] Extensive unit testing. Many of the cases were borrowed from the Golang Reference implementation
- [x] End to end testing (exporting data via an OTel collector to a metric backend)
Checklist:
- [x] Followed the style guidelines of this project
- [x] Unit tests have been added
- [x] Documentation has been updated (there are docs in the source code, we'll likely need to do a pass on metrics docs at some point).
Codecov Report
Merging #3498 (46eecbb) into main (1c3af6c) will increase coverage by
0.21%
. The diff coverage is97.19%
.
:exclamation: Current head 46eecbb differs from pull request most recent head e293cdd. Consider uploading reports for the commit e293cdd to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #3498 +/- ##
==========================================
+ Coverage 93.74% 93.95% +0.21%
==========================================
Files 249 256 +7
Lines 7593 8057 +464
Branches 1582 1673 +91
==========================================
+ Hits 7118 7570 +452
- Misses 475 487 +12
Impacted Files | Coverage Δ | |
---|---|---|
...tal/packages/otlp-transformer/src/metrics/types.ts | 100.00% <ø> (ø) |
|
packages/sdk-metrics/src/export/MetricData.ts | 100.00% <ø> (ø) |
|
packages/sdk-metrics/src/view/Aggregation.ts | 93.82% <55.55%> (-4.79%) |
:arrow_down: |
...trics/src/aggregator/exponential-histogram/util.ts | 94.11% <94.11%> (ø) |
|
...sdk-metrics/src/aggregator/ExponentialHistogram.ts | 97.18% <97.18%> (ø) |
|
...cs/src/aggregator/exponential-histogram/Buckets.ts | 98.01% <98.01%> (ø) |
|
.../packages/otlp-transformer/src/metrics/internal.ts | 98.00% <100.00%> (+0.27%) |
:arrow_up: |
...r/exponential-histogram/mapping/ExponentMapping.ts | 100.00% <100.00%> (ø) |
|
.../exponential-histogram/mapping/LogarithmMapping.ts | 100.00% <100.00%> (ø) |
|
...ggregator/exponential-histogram/mapping/ieee754.ts | 100.00% <100.00%> (ø) |
|
... and 4 more |
Based on the discussion at the SIG meeting earlier today, I split this PR into three parts. See:
I'll leave this draft PR open so folks can see the three parts combined.
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
I'm closing this PR as all three parts (see below) have merged :tada:
Thank you again, @mwear, for putting in all the work and sticking with us during the reviews :slightly_smiling_face: