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
Exemplar API sketch #641
Exemplar API sketch #641
Conversation
/** | ||
* Increment the counter by given amount and update the exemplar for the series. | ||
* | ||
* @param amt the amount to increment the counter by | ||
* @param exemplarLabels a set of key value pairs used to create the exemplar | ||
* | ||
* @throws IllegalArgumentException If amt is negative. | ||
* @throws IllegalArgumentException if exemplarLabels is null. | ||
* @throws IllegalArgumentException if exemplarLabels does not contain an even number of values. | ||
* @throws IllegalArgumentException if exemplarLabels contains any invalid labels. | ||
* @throws IllegalArgumentException if the combined length of the exemplarLabels is greater than 64. | ||
*/ |
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.
Initial golang documentation that I can probably borrow from a little more heavily:
https://github.com/prometheus/client_golang/blob/c32ffd121f40843d8ce747536467bb091678fd87/prometheus/counter.go#L44-L51
There were two things I wanted to point out here.
Do we want to copy the go behavior of ignoring null labels?
I'm inclined to say that null labels are invalid and that the user should use inc
instead.
Exceptions for invalid labels scare me a bit as well. Having instrumentation code throw an exception because your dynamically generated label ended up a little too long sounds like a not fun user experience, but I don't have a better alternative other than logging an error or incrementing an internal error counter.
Signed-off-by: Andrew Fitzgerald <andrewcfitzgerald@gmail.com>
Signed-off-by: Andrew Fitzgerald <andrewcfitzgerald@gmail.com>
Thanks a lot for picking this up again. I continued the discussion in #622. |
I just merged Exemplar support to the |
Expending a comment from #622 to a PR.
This PR proposes an API for recording exemplar values on counters and histograms.
Adds new
<inc|add>WithExemplar(double value, String... exemplarLabels)
methods which take string varargs containing exemplar values.Inspired by initial golang implementation by @beorn7 : prometheus/client_golang#706
Not addressed
Intentionally omitted
Counter#incWithExemplar(String... examplarLabels)
increment by 1 convenience method (less duplication in the API, forcing the user to include an amount felt reasonable if they're already using the more verbose method).@fstab @tomwilkie