rotationalio / radish

A stateless asynchronous task queue and handler framework
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Metrics flexibility #12

Open bbengfort opened 4 years ago

bbengfort commented 4 years ago

We'd like the prometheus metrics to be flexible to our library users. E.g. we don't want to panic with prometheus.MustRegister and give the user some ability to control the registration of the metrics.

Potentially we should add a sync.Once around the register metrics call, and keep track if the registration has occurred using an internal flag. Then when we actually use the metrics we can check the flag to ensure they've been registered or do nothing if they haven't been. The question is what happens if we call the metrics without registering, is it just a noop or do they panic? (My hypothesis is that it's just a noop but we need to test this).

See #11

bbengfort commented 4 years ago

Update: we've added a SuppressMetrics flag to the config that the server respects, e.g. if the radish service listens and SuppressMetrics is false then the server registers the metrics (returning an error) and serves them in their own goroutine; if true, the server does nothing.

This is better, but still leaves questions:

  1. When we call metrics without having registered them, what happens?
  2. What if the user wants to implement their own Radish server?