Add optional Prometheus metrics endpoint for runner scale set statistics#62
Conversation
… polling, and opt-in endpoint
|
|
||
| var runnerScaleSetIDs = []int{} | ||
|
|
||
| type Metrics struct { |
There was a problem hiding this comment.
I would suggest moving the metrics related code to a separate file (and type). This would keep the main file relatively small and the metrics ligic can be concentrated in one place.
In addition to that the start of the metrics sever together with the metrics polling can be done in the same func (for example called Start).
There was a problem hiding this comment.
Thanks for the suggestion! I’ve refactored the metrics implementation accordingly.
Moved all metrics-related logic into a dedicated metrics package (pkg/metrics/metrics.go)
Introduced a Start function that encapsulates both:
- the metrics HTTP server
- the metrics polling loop
Simplified main.go so it only handles orchestration and conditionally enables metrics via ENABLE_METRICS
This keeps main.go smaller and centralizes all metrics behavior in one place for better separation of concerns.
…labeled Prometheus metrics and configurable polling
| LogLevelEnvName = "LOG_LEVEL" | ||
|
|
||
| // Prometheus metrics | ||
| EnableMetricsEnvName = "ENABLE_METRICS" |
There was a problem hiding this comment.
Two things I've missed the first time:
- Let's update the readme with these new env vars explaining what they are
- Let's add them to the example .env file
|
Tested the change and it works perfectly. |
ispasov
left a comment
There was a problem hiding this comment.
Thank you for your contribution.
This looks great!
This PR adds Prometheus metrics for runner scale set statistics and exposes them via /metrics when enabled.
Included metrics:
Implementation details:
metrics are opt-in via
ENABLE_METRICSmetrics endpoint address is configurable via
METRICS_ADDRmetrics polling interval is configurable via
METRICS_POLL_INTERVALmetrics use a dedicated Prometheus registry instead of the global registry
metrics include a runner_name label to identify the runner scale set