Fork me on GitHub

I'm looking into moving our observability pipeline from statsd to prometheus - so far looks great, but one thing bugs me: why do I have to define metrics upfront? Is there a way of adding them dynamically that doesn't involve rebuilding the registry all the time? I tried to find answer for this and there's no clear answer anywhere or my google-fu is simply not good enough. thx 🙏


what do you mean by rebuilding a registry? the registry is initialized with collectors and you can hold a reference to a collector and register metrics to that, mutably/dynamically


The readme clearly states: "All metrics have to be registered with a collector registry before being used" - so that's pretty clear to me that I need to know all metrics upfront. For the most part that's how we use statsd, but we also have a http router that creates metrics for all routes automatically, so generate all metric keys when the route configuration is read. I realize I can hook into the metric registration process but it will weirdly couple the metric collector with our router.