zio / zio-zmx

Monitoring, Metrics and Diagnostics for ZIO
https://zio.github.io/zio-zmx/
Apache License 2.0
85 stars 47 forks source link

Implement ZIO-based Counter #46

Closed toxicafunk closed 3 years ago

toxicafunk commented 4 years ago

Implement monotonically increasing counter as described in https://prometheus.io/docs/instrumenting/writing_clientlibs/#counter

adamgfraser commented 3 years ago

Are these for the Prometheus implementation of the Metrics service? Or were you thinking about having this functionality more generally? I guess same question applies to the other related tickets.

toxicafunk commented 3 years ago

Initially I have though of creating a full-on, complete ZIO-based P{rometheus client, but given the way zmx basically queues metrics on a Ring and how we deal with them:

https://github.com/zio/zio-zmx/blob/da7685cd614fd736950abb9f4cd79e9422f949e9/src/main/scala/zio/package.scala#L352

Now I think it may be better to just implement the Collectors and then implement a write004 function that format them as Prometheus expects.

So instead of having the user specify how to deal with prometheus:

https://github.com/zio/zio-zmx/blob/da7685cd614fd736950abb9f4cd79e9422f949e9/src/test/scala/zio/PrometheusSpec.scala#L65

we can provide the correct functions ourselves which will use said collectors and write004 function: https://github.com/zio/zio-zmx/blob/da7685cd614fd736950abb9f4cd79e9422f949e9/src/test/scala/zio/PrometheusSpec.scala#L53