Skip to content

Integrate Golang metrics server with Rails app

Matthias Käppler requested to merge 358025-integrate-gme into master

What does this MR do and why?

We are replacing the dedicated Ruby server that serves application metrics into Prometheus (web_exporter, sidekiq_exporter) with a new component: gitlab-metrics-exporter. This is a new metrics server written from scratch in Go, which can read mmap metric files written by the application and serve them to a scraper. Just like the Ruby server now, it runs as a sidecar process alongside gitlab-rails.

The new server is activated via an environment variable: GITLAB_GOLANG_METRICS_SERVER. It is off by default, so shipping this MR should have no observable effect, for now.

What this MR does:

  • Add a rake task that both code and end-users can invoke to compile and install the Golang server
  • Integrate it with the MetricsServer Ruby wrapper; this is the class that will spawn either the Ruby server (old) or the Go server (new)
  • Extend the server end-to-end spec to make sure both servers are functional as we perform this migration over time. This is just a smoke test to verify the server starts, binds to the correct address, and services requests. We will add more extensive testing later.

Related to #358025 (closed)

How to set up and validate locally

The GDK work is not done yet for this, so setting up the server for ordinary use isn't very convenient, yet.

  1. Install the server e.g. via bin/rake gitlab:metrics_exporter:install[tmp/gme]
  2. Make sure the tmp/gme/bin directory is on PATH
  3. Set the GITLAB_GOLANG_METRICS_SERVER env var to something truthy
  4. Make sure web_exporter, sidekiq_exporter or both are enabled (under monitoring in gitlab.yml)
  5. Start either Rails or Sidekiq or both
  6. When boot finishes, you should see a new process running, gitlab-metrics-exporter listening on the port configured. It serves /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.

Edited by Matthias Käppler

Merge request reports