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
- Run CB via Kurtosis with a config containing
[metrics] host = "0.0.0.0" port = 9090
- Exec into the container:
kurtosis service exec <enclave> <cb-service> "curl -s http://localhost:9090/metrics"
- Connection refused. The metrics server never started.
When running
commit-boost pbsoutside ofcb docker init(e.g., in a Kurtosis devnet via the ethereum-package), the metrics server never starts even when[metrics]is configured incb-config.toml.Root cause
MetricsProvider::load_and_run()reads the metrics port exclusively from theCB_METRICS_PORTenv var viaModuleMetricsConfig::load_from_env(). This env var is only set bydocker_init.rswhen generating docker-compose files. In any other deployment model the env var is absent,load_from_env()returnsNone, and the metrics server is skipped with"No metrics server configured".The
[metrics]block in the config file is parsed intoCommitBoostConfig.metricsbut 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:This preserves the existing behavior when
docker_initsets the env var (env takes precedence) and enables metrics in all other deployment modes.Reproduction
[metrics] host = "0.0.0.0" port = 9090kurtosis service exec <enclave> <cb-service> "curl -s http://localhost:9090/metrics"