-
Notifications
You must be signed in to change notification settings - Fork 821
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
feat(sdk-metrics-base): implement min/max recording for Histograms #3032
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3032 +/- ##
==========================================
- Coverage 92.65% 92.64% -0.01%
==========================================
Files 187 187
Lines 6178 6198 +20
Branches 1304 1314 +10
==========================================
+ Hits 5724 5742 +18
- Misses 454 456 +2
|
experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/Histogram.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/Histogram.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really makes me wish we had gone the route of having the histogram delta by default but oh well. Overall LGTM and i'm glad to have this feature in
@dyladan I'm not getting what you are pointing at. Would you mind elaborating on this? I'd be happy to find out if we can do it in a better way. |
if(histogram.hasMinMax){ | ||
return { | ||
attributes: toAttributes(dataPoint.attributes), | ||
bucketCounts: histogram.buckets.counts, | ||
explicitBounds: histogram.buckets.boundaries, | ||
count: histogram.count, | ||
sum: histogram.sum, | ||
min: histogram.min, | ||
max: histogram.max, | ||
startTimeUnixNano: hrTimeToNanoseconds(dataPoint.startTime), | ||
timeUnixNano: hrTimeToNanoseconds( | ||
dataPoint.endTime | ||
), | ||
}; | ||
} else { | ||
return { | ||
attributes: toAttributes(dataPoint.attributes), | ||
bucketCounts: histogram.buckets.counts, | ||
explicitBounds: histogram.buckets.boundaries, | ||
count: histogram.count, | ||
sum: histogram.sum, | ||
startTimeUnixNano: hrTimeToNanoseconds(dataPoint.startTime), | ||
timeUnixNano: hrTimeToNanoseconds( | ||
dataPoint.endTime | ||
), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this if/else? If min and max are not there won't they simply be undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. For some reason I thought that this was necessary, but it is not. 😅
I simplified this in b23b6f1. 🙂
min
/max
are not undefined when they get here, though (they are Inf
and -1
), so I still need to check hasMinMax
and set undefined
explicitly.
Sorry I confused myself a bit while reviewing. I was looking to see where merge is called and got a bit lost in the details of the SDK. I don't remember what I was specifically looking at when I made that comment sorry. |
Look like it's related to the way It was very elegant before, but now it's kind of counfusing. 😓 |
@pichlermarc I can not edit this PR so please update the PR with the latest main branch so that we can land this one :). |
Which problem is this PR solving?
The Metrics SDK spec defines an option
RecordMinMax
to turn on or offmin
andmax
recordings on Explicit Bucket Histogram Aggregations.This PR:
min
/max
recording to HistogramsExplicitBucketHistogramAggregation
min
andmax
can be exportedFixes #3010
Type of change
http
receiver drops JSON requests with extra keys opentelemetry-collector#5312)How Has This Been Tested?
Checklist: