-
Notifications
You must be signed in to change notification settings - Fork 162
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
Honorning buckets passed as part of PrometheusMetrics initialization … #174 #175
base: master
Are you sure you want to change the base?
Conversation
@@ -679,6 +679,10 @@ def _track(self, metric_type, metric_call, metric_kwargs, name, description, lab | |||
|
|||
labels = self._get_combined_labels(labels) | |||
|
|||
if metric_type is Histogram: |
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.
OK, I think the change is good, but I'm not sure this should hang off self.buckets
.
The doc on that one says
:param buckets: the time buckets for request latencies (will use the default when `None`)
So up until now, it would only affect the default request latency metrics the library adds, not the manually decorated histogram metrics (you can add buckets=(...)
on those specifically).
If you'd like to avoid duplicating the buckets, you can either make it a variable, or we could look at adding a default_histogram_buckets
parameter here instead.
What do you think?
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.
Hi,
I dont think I fully got it. What do you mean by
If you'd like to avoid duplicating the buckets, you can either make it a variable, or we could look at adding a default_histogram_buckets parameter here instead.
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 meant, from your example, you could do this:
buckets = (0.005, 0.1, 0.2, INF)
metrics = PrometheusMetrics(app, buckets=buckets)
shorten_url_duration = metrics.histogram('shorten_url_duration', 'Duration of shorten_url call', buckets=buckets)
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 was already doing that :P
But shouldn't the buckets which got passed during PrometheusMetrics initialization be honored while creating a histogram metrics.
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.
We could do that, but we would change what that buckets
parameter does currently on PrometheusMetrics
where the docs say the time buckets for request latencies, which is why I suggested that perhaps a different variable could work there as some consumers might use this parameter currently and expect it to only apply to request latencies but not to custom histograms.
At that point though, manually declaring the buckets there may be cleaner?
Honoring buckets passed as part of PrometheusMetrics initialization in Histogram metrics.