deadtrickster / prometheus.erl

Prometheus.io client in Erlang
MIT License
341 stars 117 forks source link

Allow application to pre-render labels for text format #137

Closed binarin closed 2 years ago

binarin commented 2 years ago

Builds on top of #136

This is useful when application know what it is doing, e.g. when escaping is not needed. In RabbitMQ case this is because object names are restricted only to those characters that don't need escaping.

This change provides not only direct speedup, but also significantly reduced garbage collection overhead, as for every output line the proplist with labels and the list with converted #'LabelPair'{}'s are replaced with just a single binary.

Using RabbitMQ as an example, time to produce ~630k metrics went from ~6 to ~3 seconds.

Downside is that it's only compatible with text format, and spec for `#'LabelPair'{}' is not respected.