discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
532 stars 154 forks source link

Add a way to simply add per-request/per-job metrics #206

Open fsateler opened 2 years ago

fsateler commented 2 years ago

Hi!

Thanks for this awesome gem.

This may be a documentation issue. I found that adding new per-request or per-job metrics is a bit annoying because:

  1. A custom collector needs to be added to pick up the new metrics.
  2. In the web case, the Middleware might be extended, or a new one created to send the new metrics
  3. In the job case, this is even worse because delayed_job (what I use) creates a dynamic class so there is no way to extend it, a new plugin is needed.

Ideally one would be able to register new metrics declaratively, and "attach" them to the current context somehow. This way the labels the default plugins use get used as well for the new metrics.

If given some guidance on how to best approach this, I'm happy to take a stab at implementing (or documenting if this is already possible)