Skip to content

Metrics server doesn't start in non-docker-init deployments #446

@JasonVranek

Description

@JasonVranek

When running commit-boost pbs outside of cb docker init (e.g., in a Kurtosis devnet via the ethereum-package), the metrics server never starts even when [metrics] is configured in cb-config.toml.

Root cause

MetricsProvider::load_and_run() reads the metrics port exclusively from the CB_METRICS_PORT env var via ModuleMetricsConfig::load_from_env(). This env var is only set by docker_init.rs when generating docker-compose files. In any other deployment model the env var is absent, load_from_env() returns None, and the metrics server is skipped with "No metrics server configured".

The [metrics] block in the config file is parsed into CommitBoostConfig.metrics but never consulted at runtime by the PBS service.

Suggested fix

In load_pbs_config() (crates/common/src/config/pbs.rs), after loading the config, set the env var from the config when it isn't already present:

if std::env::var(METRICS_PORT_ENV).is_err() {
    if let Some(ref metrics) = config.metrics {
        if metrics.enabled {
            std::env::set_var(METRICS_PORT_ENV, metrics.start_port.to_string());
        }
    }
}

This preserves the existing behavior when docker_init sets the env var (env takes precedence) and enables metrics in all other deployment modes.

Reproduction

  1. Run CB via Kurtosis with a config containing [metrics] host = "0.0.0.0" port = 9090
  2. Exec into the container: kurtosis service exec <enclave> <cb-service> "curl -s http://localhost:9090/metrics"
  3. Connection refused. The metrics server never started.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions