eclipse / microprofile-metrics

microprofile-metrics
Apache License 2.0
100 stars 66 forks source link

Provide programmatic way to register global or registry-level tags #600

Open aseovic opened 4 years ago

aseovic commented 4 years ago

At the moment the only way to register global tags is via configuration. This is less than ideal for frameworks and libraries that need to add some global tags to all metrics published from the process in order to disambiguate them across the system.

In our case (Coherence), we have a situation where we could have metrics with the same name and tags published from many cluster members unless we disambiguate them by adding cluster name and member ID as tags. These are not tags that users could configure themselves, as the values for them may not be known at configuration time and are only available at runtime.

Ideally, there should be a standard, spec-defined way of registering custom global (or registry-level) tags programmatically, so we can rely on it for integration regardless of which MP implementation is used.

ebullient commented 4 years ago

Just a clarifying question: not known until runtime means programmatically retrieved? Could tags be obtained via config injection (and thus read when the runtime instance starts using the usual MP Config API?)

aseovic commented 4 years ago

Correct, they are programmatically retrieved.

And yes, I am using a custom config source now to override/append to global tags MP Metrics already reads from configuration, but it's an ugly hack that shouldn't be necessary.