zio / zio-metrics-connectors

Monitoring, Metrics and Diagnostics for ZIO
https://zio.dev/zio-metrics-connectors
Apache License 2.0
30 stars 24 forks source link

Provide way to set default tags for all metrics #5

Open domdorn opened 2 years ago

domdorn commented 2 years ago

I need to have a way to add certain tags to all metrics, e.g. I want to globally create a tag "application" with value "myApp" that then gets added to all metrics, e.g.

the response from the prometheus endpoint:

$ curl -i http://localhost:8080/metrics
HTTP/1.1 200 OK
content-type: text/plain
content-length: 278

# TYPE count_all_requests counter
# HELP count_all_requests Some help
count_all_requests{method="POST",handler="/users"}  2.0 1655210796102
# TYPE count_all_requests counter
# HELP count_all_requests Some help
count_all_requests{method="GET",handler="/users"}  1.0 1655210796102⏎

changes to

$ curl -i http://localhost:8080/metrics
HTTP/1.1 200 OK
content-type: text/plain
content-length: 278

# TYPE count_all_requests counter
# HELP count_all_requests Some help
count_all_requests{application="myApp",method="POST",handler="/users"}  2.0 1655210796102
# TYPE count_all_requests counter
# HELP count_all_requests Some help
count_all_requests{application="myApp",method="GET",handler="/users"}  1.0 1655210796102⏎
Grryum commented 1 year ago

seems that this issue should be addressed to zio repository