rycus86 / prometheus_flask_exporter

Prometheus exporter for Flask applications
https://pypi.python.org/pypi/prometheus-flask-exporter
MIT License
646 stars 161 forks source link

Adding support for honoring buckets passed as part of creating Promet… #173

Closed Rdgarg closed 8 months ago

Rdgarg commented 8 months ago

…heusClient

rycus86 commented 8 months ago

Hi,

Thanks for opening this PR! Is there a specific problem you're solving? Is there perhaps a unit test you could add to go with this change?

Thanks!

coveralls commented 8 months ago

Coverage Status

coverage: 84.483% (+0.9%) from 83.617% when pulling d11c7b31567d7279dbff5d4cd03af2f8351f904a on Rdgarg:master into 9e20f3fbb381d81de93c19afaaffdcec139aebfa on rycus86:master.

Rdgarg commented 8 months ago

Hi ,

Recently I stumbled on one issue in which histogram metrics were not honoring the buckets passed during PrometheusMetrics initialization.

Code snippet

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')

Sample Response

shorten_url_duration_bucket{le="0.005"} 0.0
shorten_url_duration_bucket{le="0.01"} 0.0
shorten_url_duration_bucket{le="0.025"} 0.0
shorten_url_duration_bucket{le="0.05"} 0.0
shorten_url_duration_bucket{le="0.075"} 0.0
shorten_url_duration_bucket{le="0.1"} 0.0
shorten_url_duration_bucket{le="0.25"} 0.0
shorten_url_duration_bucket{le="0.5"} 0.0
shorten_url_duration_bucket{le="0.75"} 0.0
shorten_url_duration_bucket{le="1.0"} 0.0
shorten_url_duration_bucket{le="2.5"} 0.0
shorten_url_duration_bucket{le="5.0"} 0.0
shorten_url_duration_bucket{le="7.5"} 0.0
shorten_url_duration_bucket{le="10.0"} 0.0
shorten_url_duration_bucket{le="+Inf"} 0.0

Expected Response

shorten_url_duration_bucket{le="0.005"} 0.0
shorten_url_duration_bucket{le="0.1"} 0.0
shorten_url_duration_bucket{le="0.2"} 0.0
shorten_url_duration_bucket{le="+Inf"} 0.0
Rdgarg commented 8 months ago

Will add unit tests, mistakenely this PR got raised to the original repo instead of my fork :( Sorry