-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add exemplar support for const histogram #986
Add exemplar support for const histogram #986
Conversation
a8e5096
to
06d7406
Compare
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.
prometheus/histogram.go
Outdated
@@ -655,6 +670,48 @@ func MustNewConstHistogram( | |||
return m | |||
} | |||
|
|||
func NewConstHistogramWithExemplar( |
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.
Can we use NewConstHistogramWithExemplar
in NewConstHistogram
for less code repetition?
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.
Just to clarify, did you mean to use NewConstHistogram
inside NewConstHistogramWithExemplar
? My goal was to keep the existing API unchanged but whatever you folks prefer is fine by me.
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.
no, opposite. I think you misunderstood, let me show in PR to your PR 🙃
Counters can also have exemplars. Instead of also adding |
It would also avoid having to add the |
06d7406
to
d9d40e2
Compare
So I started looking into this last Friday and it's less straight forward than that comment makes it seem. |
Indeed, a And yes, the |
Hey folks, so I've been looking into a potential From what I understand there’s 4 Metrics that can have exemplars: ExemplarAdder, ExemplarObserver, constMetric and constHistogram. For the first two, the layer of abstraction doesn’t add a lot, it ends up just doing what ppl are already doing right now, asserting that the metric implements the interface, then just call AddWithExemplar or ObserveWithExemplar. For the last two, the data they need is so different I’m struggling to find a way to make a function signature that would work with both of them that would also be clear enough. For reference, here are what the current signatures look like:
To add exemplars, the first one needs a []*dto.Exemplar because each bucket has it’s own exemplar, and the second one needs I can add a |
0edd2e5
to
65e8cde
Compare
Hmm, I increasingly believe there is no real good way of solving this in the current context. I really don't like to expose I think, from a pure interface perspective, the least bad solution would be a
The last point is the most "dirty" aspect of this, but maybe it's OK (think of the function as "add an exemplar to this metric if it makes sense"). It's slightly annoying that you have to call So maybe, overall, the approach in this PR is already the least bad. I don't know. @bwplotka and @kakkoyun you should make the call here. 😸 |
Hey folks, any updates on this PR? |
Ack, we will sync on it with @kakkoyun on Monday. Thanks! |
Co-authored-by: William Perron <[email protected]> Signed-off-by: William Perron <[email protected]>
Signed-off-by: William Perron <[email protected]>
reduce repetition in constHistogram w/ exemplar Signed-off-by: William Perron <[email protected]>
Signed-off-by: William Perron <[email protected]>
65e8cde
to
47d3c54
Compare
Co-authored-by: Francis Bogsanyi <[email protected]> Signed-off-by: William Perron <[email protected]>
Co-authored-by: Arun Mahendra <[email protected]> Signed-off-by: William Perron <[email protected]>
Hey @bwplotka I hate to be that guy but, any chance we can get a set of eyes on this soon? |
Ack, will look on Tuesday, adding to my todo list. |
Looking now, sorry for lag |
All fixed PTAL (: |
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.
Blocking this to decide what's the best approach before merging 🙃
Changes: * Make sure to not "leak" dto.Metric * Reused upper bounds we already have for histogram * Common code for all types. Signed-off-by: Bartlomiej Plotka <[email protected]>
Merged in your suggested changes, let me know if there's anything you want me to change 👍 |
Relates to #868. We're looking to add support for exemplars on OpenTelemetry's collector contrib's
prometheusexporter
which uses theconstHistogram
internally. This change solves the case where metrics coming from another system (in our case the otel collector) need to be converted to the Prometheus format and retain their exemplars. Right now we've only implemented exemplars on the const histogram, I'm more than happy to do all the necessary adjustments.