prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

add `defaultLabels` option to metric classes

Open bienzaaron opened this issue 2 years ago • 2 comments

adds a defaultLabels option to the base Metric class and updates each metric class to use the value where appropriate.

Closes #598

bienzaaron avatar Nov 26 '23 03:11 bienzaaron

Instead of applying it during metric usage, maybe it could be added at metric scrape time https://github.com/siimon/prom-client/blob/c1d76c5d497ef803f6bd90c56c713c3fa811c3e0/lib/registry.js#L55-L57

BourgoisMickael avatar Feb 27 '25 19:02 BourgoisMickael

There is default label support in the registry, which you can add each metric to.

https://github.com/siimon/prom-client/blob/4c6421b2253c9780a845889004b9a58dac646a1c/lib/registry.js#L17

Given the number of open tickets about memory and CPU pressure, and how much of that is down to the fact of labels, I think it would probably be good to use what is already there instead of adding more ways to do the slow things.

jdmarshall avatar Jul 08 '25 01:07 jdmarshall