[receiver/prometheusreceiver] Convert NHCB to explicit histogram metric#43095
Conversation
c61c27b to
957df66
Compare
|
I would like do some changes here, will open when done. |
|
In remotewrite receiver if spans are empty, bucket counts are not filled we should follow it here too, right? |
|
I believe it is filled with all zeroes by the |
|
ready for review |
ArthurSens
left a comment
There was a problem hiding this comment.
Thanks for working on this one! It looks almost ready, to be honest. I think we can improve a little bit on the readability of the getOrCreatedMetricFamily method, adding -1 in almost all calls of that function is looking weird 🤔
| // getOrCreateMetricFamily returns the metric family for the given metric name and scope, | ||
| // and true if an existing family was found. | ||
| func (t *transaction) getOrCreateMetricFamily(key resourceKey, scope scopeID, mn string) *metricFamily { | ||
| func (t *transaction) getOrCreateMetricFamily(key resourceKey, scope scopeID, mn string, schema int32) *metricFamily { |
There was a problem hiding this comment.
Something feels off with this strategy of adding a schema as an argument 🤔
What if we took a similar approach to the one we use when detecting a NativeHistogram? When we call AppendHistogram, we toggle a flag in the transaction object called addingNativeHistogram. Couldn't we add the flag there, too?
There was a problem hiding this comment.
yes that sounds good too
| var schema int32 | ||
| if h != nil { | ||
| schema = h.Schema | ||
| } else if fh != nil { | ||
| schema = fh.Schema | ||
| } | ||
| t.addingNativeHistogram = true |
There was a problem hiding this comment.
This is the place I had in mind in the comment above. Couldn't we add a second flag here, e.g.
var schema int32
if h != nil {
schema = h.Schema
} else if fh != nil {
schema = fh.Schema
}
t.addingNativeHistogram = true
if schema == -53 {
t.addingNHCB = true
}If we use that flag when calling getOrCreateMetricFamily, then the schema argument isn't needed and we don't need to add -1 in weird places 😅
| if curMf.mtype == pmetric.MetricTypeHistogram && mfKey.isExponentialHistogram { | ||
| curMf.mtype = pmetric.MetricTypeExponentialHistogram | ||
| // Don't convert NHCB to ExponentialHistogram. | ||
| if schema != -53 { | ||
| curMf.mtype = pmetric.MetricTypeExponentialHistogram | ||
| } | ||
| } |
There was a problem hiding this comment.
I believe this could become a single if...?
|
oh changelog got new validations, will fix |
|
ah chlog files from prev release |
cdd2b3c to
1780f80
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
LGTM, but I'd love it if we could wait for @dashpole or @krajorama's review as well
|
huh, something strange happened with my comments. Maybe I didn't actually leave them? Edit: Re-posted it below |
Co-authored-by: David Ashpole <dashpole@google.com>
|
Thank you for your contribution @jelly-afk! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help. |
…ic (open-telemetry#43095) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description added prometheus NHCB (native histogram with custom buckets) to otel explicit histogram conversion. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#41131 <!--Describe what testing was performed and which tests were added.--> #### Testing Added `TestMetricGroupData_toNHCBDistributionUnitTest` test function to test the conversion. --------- Co-authored-by: David Ashpole <dashpole@google.com>
Description
added prometheus NHCB (native histogram with custom buckets) to otel explicit histogram conversion.
Link to tracking issue
Fixes #41131
Testing
Added
TestMetricGroupData_toNHCBDistributionUnitTesttest function to test the conversion.