PromPHP / prometheus_client_php

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

[RenderTextFormat] Allow value errors to be rendered as comments #142

Closed joec4i closed 8 months ago

joec4i commented 8 months ago

This PR addresses a specific scenario encountered with Redis and RedisNg storage, where samples with mismatching labels can be stored. For instance:

127.0.0.1:6379> hgetall PROMETHEUS_:counter:foo_bar
1) "[\"bob\",\"alice\",\"eve\"]"
2) "1"
3) "__meta"
4) "{\"name\":\"foo_bar\",\"help\":\"counter-help-text\",\"type\":\"counter\",\"labelNames\":[\"label1\",\"label2\"]}"
5) "[\"bob\",\"alice\"]"
6) "1"

In the above example, the counter metadata specifies label1 and label2 but it's possible to store samples with more or fewer labels, e.g.["bob","alice","eve"]. This could happen under different circumstances. For example, a new version of the code introduces label3 for the counter.

Depending on the setup, flushing the storage after the new code is out could be a valid way to avoid the problem. However, it becomes complex in environments with canary deployment where multiple versions of the code are required to run together.

While there are ways to avoid the scenario, offering users the option to ignore errors for a limited number of metrics can be beneficial. It avoids the complete failure of the rendering operation in cases of minor inconsistencies. This PR does that.

Thanks for reviewing this! 🙏

LKaemmerling commented 8 months ago

And released as v2.9.0 :) I guess this is a new world record, 9 min from opening of the MR, till merging & releasing :)

joec4i commented 8 months ago

🤣 Thanks @LKaemmerling !