Jimdo / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
281 stars 213 forks source link

Resetable counter #35

Open krukru opened 7 years ago

krukru commented 7 years ago

I couldn't find a way to reset the counter values to zero (since they persist in Redis/APC) so I added a reset method.

bracki commented 6 years ago

What's your use case for resetting counters?

krukru commented 6 years ago

For example, we keep track of the number of successful/failed http requests since the last server restart. I guess that this could be handled with a workaround (labels), but it seemed just practical to reset the counters on a server crash and start counting again from 0.

bracki commented 6 years ago

Ah, so you want to reset metrics in Redis, correct? Because with APC they would automatically be resetted.

krukru commented 6 years ago

Right, APC would be reset since it is not persistent. But Redis (and a theoretical File Storage adapter) would require this to be reset.

bracki commented 6 years ago

OK, but wouldn't it make sense than to add this to every possible metric?

krukru commented 6 years ago

Well, you are right on that account :) If you think this is a good PR I can update it to include other metrics as well (not just Counter)

jitendra-1217 commented 6 years ago

But how does it matter to prometheus, it anyway handles counter resets doing some normalisation, right? I am just curious how do you end up using this data.