-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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 histogram exemplar support #124013
base: master
Are you sure you want to change the base?
Add histogram exemplar support #124013
Conversation
Skipping CI for Draft Pull Request. |
func (noopMetric) Set(float64) {} | ||
func (noopMetric) Sub(float64) {} | ||
func (noopMetric) Observe(float64) {} | ||
func (noopMetric) ObserveWithExemplar(float64, prometheus.Labels) {} |
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.
I'm revisiting this after a good while but IIRC from a discussion with @logicalhan around exemplar support for counters, we want to modify the existing methods implicitly (without modifying their signatures) to support exemplars OOTB.
Additionally, my understanding is that we don't want to make any component directly dependent on prometheus/client_golang
, but incorporate that behavior into component-base
and have them import that instead, in an effort to be able to offset any breaking changes and not having to send patches upstream (and catering to any extra use-cases specific to k/k
).
All components themselves will be responsible for "attaching" exemplars within their contexts, if they want to utilize this feature-set, but we won't have to make any explicit changes in any component for this feature-set to work. However, the SIG can help components benefit from this by patching their contexts for them, but I believe that is out of the scope of this effort (adding exemplar support to component-base
).
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 the pointers @rexagod. The initial version of this PR was mostly a POC to verify that we are able to see exemplars after-all in metrics, hence admittedly had quite a lot of hacky stuff going on at first.
I modified this PR now, following what you are doing for counters in #119949, though it still needs to use the component-base.metrics.exemplarMetric
that you have introduced, so I'll wait for that PR to merge first and make those changes then.
Additionally I am wondering, if we need to introduce Add()/Observe() methods for CounterVec/HistogramVec too?
8a0d72c
to
eeab583
Compare
eeab583
to
a86cef8
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.
/assign
/triage accepted
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.
lgtm with one nit
h.withExemplar(v) | ||
} | ||
|
||
func (h *Histogram) withExemplar(v float64) { | ||
(&exemplarHistogram{h}).withExemplar(v) | ||
} | ||
|
||
func (h *exemplarHistogram) withExemplar(v float64) { |
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 you need the extra exemplarHistogram
type and the withExemplar functions.
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.
Good catch, I don't. Can't remember why I did that, removed it now.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: richabanker The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
same comments for exemplarHistogramVec
"span_id": maybeSpanCtx.SpanID().String(), | ||
} | ||
} | ||
if m, ok := h.ObserverMetric.(prometheus.ExemplarObserver); ok { |
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.
is this always going to be true? Should we fall back to the regular observe if it isn't an examplar observer?
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.
I am not sure... but still, added a fallback to use the regular Observe() flow.
} | ||
|
||
func (h *Histogram) withExemplar(v float64) { | ||
var exemplarLabels prometheus.Labels |
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.
Should we move this inside the if
statement below to avoid unnecessary computation?
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.
Sounds good, moved.
I need to wrap the return value of |
@richabanker: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds exemplar support for histograms
Which issue(s) this PR fixes:
Fixes #119697
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: