PromPHP / prometheus_client_php

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

Counters, gauges and histograms init with zero values #44

Open EdgarSedov opened 3 years ago

EdgarSedov commented 3 years ago

Atm u can't create histogram with zero value upfront (for correct grafana increase function to work), because it will increment _count and mess with averages in future. It would be nice to have initialization mechanics (for example, on register method), as discussed in other clients, like here or here

I'm not that good at redis and lua, i've looked into current updateSomething realizations for redis and couln't come up with solution, but if u'll point me in right direction, i think i can try to help

LKaemmerling commented 3 years ago

Hey @EdgarSedov,

good point! I already looked a bit into the code and I don't think this is easy solvable. The "problem" is that we only set the value/metric when you call inc/set/observe on the specific metric types. Before it does not "reach" the underlying storage and will be "thrown" away. I will think about it a bit more, but I think we can not fix it with the current architecture for this library.

EdgarSedov commented 3 years ago

@LKaemmerling Hi' i've made a draft with possible solution, please take a look when u'll have some time

jaugustin commented 1 year ago

@LKaemmerling is there any plan on this ? I saw the PR didn't move since 2 years ?