Skip to content

Allow `metrics_server` to target Puma

Matthias Käppler requested to merge 350546-puma-metrics-server-support into master

What does this MR do and why?

In &6409 (closed) we introduced a mechanism to spawn a dedicated metrics server process from Sidekiq via the metrics_server module. We are now looking to do the same for Puma in &7304 (closed). It was originally written in a way to be agnostic of what it is monitoring, but we never tested it with Puma and there were some fixes necessary for it to actually work.

This MR makes the necessary changes for the server process to target Puma metrics without actually activating the server process yet, i.e. it is just a refactor to move the necessary pieces into place. Nothing should change when we deploy this.

How to set up and validate locally

We can verify locally that running the WebExporter in a server process outside of Rails works via the bin/metrics-server process wrapper:

METRICS_SERVER_TARGET=puma bin/metrics-server

This should start the server on localhost, assuming the web_exporter and prometheus metrics are enabled, e.g.:

  development:
    monitoring:
      web_exporter:
        enabled: true
        address: localhost
        port: 3809

in gitlab.yml

You can then fetch metrics like so:

curl localhost:3809/metrics 

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #350546 (closed)

Edited by Matthias Käppler

Merge request reports