-
Notifications
You must be signed in to change notification settings - Fork 810
Description
Context and scope
In test runs (e.g., re-execution), avalanchego
only exposes metrics when METRICS_ENABLED
is set. That path currently (a) starts a Prometheus agent configured for remote write and (b) opens a metrics HTTP server on a random port. For firewood re-execution tests, we want to pull metrics locally (scrape /ext/metrics
) without starting Prometheus agent/remote write and need a deterministic way to discover or set the listen port. We need these changes so we can configure our own Prometheus to scrape from it and monitor the metrics using Grafana during the re-execution test.
References:
- random port bind in tests:
avalanchego/tests/prometheus_server.go
Line 17 in 47550e9
const defaultPrometheusListenAddr = "127.0.0.1:0" - metrics-enabled path that starts both agent and server:
avalanchego/tests/reexecute/c/vm_reexecute_test.go
Lines 544 to 555 in 47550e9
func collectRegistry(tb testing.TB, name string, timeout time.Duration, gatherer prometheus.Gatherer, labels map[string]string) { r := require.New(tb) ctx, cancel := context.WithTimeout(context.Background(), timeout) tb.Cleanup(cancel) r.NoError(tmpnet.StartPrometheus(ctx, tests.NewDefaultLogger("prometheus"))) server, err := tests.NewPrometheusServer(gatherer) r.NoError(err) var sdConfigFilePath string
Discussion and alternatives
Proposed code changes:
- Refactor test metrics setup so the HTTP server and Prometheus agent can be started independently.
- Support explicit port for metrics.
We can do this in two ways:
- Split env toggles:
METRICS_SERVER_ENABLED
/METRICS_PUSH_ENABLED
. - Mode selector:
METRICS_MODE=server|push|both
.
We could also add METRICS_PORT
or agree on a constant to use instead of 0
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status