Skip to content

Commit a4b275d

Browse files
committed
comments
1 parent 27e2dfe commit a4b275d

File tree

7 files changed

+64
-50
lines changed

7 files changed

+64
-50
lines changed

config.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ SOME_ENV_VAR = "some_value"
243243
[metrics]
244244
# Whether to collect metrics
245245
# OPTIONAL, DEFAULT: true
246-
use_metrics = true
246+
enabled = true
247247
# Host to listen on for metrics
248248
# OPTIONAL, DEFAULT: 127.0.0.1
249249
host = "127.0.0.1"

crates/cli/src/docker_init.rs

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,20 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
125125
}
126126

127127
if let Some(metrics_config) = &cb_config.metrics {
128-
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
129-
ports.push(format!("{}:{}", host_endpoint, metrics_port));
130-
warnings.push(format!(
131-
"{} has an exported port on {}",
132-
module_cid, metrics_port
133-
));
134-
targets.push(format!("{host_endpoint}"));
135-
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
136-
module_envs.insert(key, val);
137-
138-
metrics_port += 1;
128+
if metrics_config.enabled {
129+
let host_endpoint =
130+
SocketAddr::from((metrics_config.host, metrics_port));
131+
ports.push(format!("{}:{}", host_endpoint, metrics_port));
132+
warnings.push(format!(
133+
"{} has an exported port on {}",
134+
module_cid, metrics_port
135+
));
136+
targets.push(format!("{host_endpoint}"));
137+
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
138+
module_envs.insert(key, val);
139+
140+
metrics_port += 1;
141+
}
139142
}
140143

141144
if log_to_file {
@@ -197,17 +200,20 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
197200
module_envs.insert(key, val);
198201
}
199202
if let Some(metrics_config) = &cb_config.metrics {
200-
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
201-
ports.push(format!("{}:{}", host_endpoint, metrics_port));
202-
warnings.push(format!(
203-
"{} has an exported port on {}",
204-
module_cid, metrics_port
205-
));
206-
targets.push(format!("{host_endpoint}"));
207-
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
208-
module_envs.insert(key, val);
209-
210-
metrics_port += 1;
203+
if metrics_config.enabled {
204+
let host_endpoint =
205+
SocketAddr::from((metrics_config.host, metrics_port));
206+
ports.push(format!("{}:{}", host_endpoint, metrics_port));
207+
warnings.push(format!(
208+
"{} has an exported port on {}",
209+
module_cid, metrics_port
210+
));
211+
targets.push(format!("{host_endpoint}"));
212+
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
213+
module_envs.insert(key, val);
214+
215+
metrics_port += 1;
216+
}
211217
}
212218
if log_to_file {
213219
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);
@@ -260,14 +266,16 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
260266
pbs_envs.insert(key, val);
261267
}
262268
if let Some(metrics_config) = &cb_config.metrics {
263-
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
264-
ports.push(format!("{}:{}", host_endpoint, metrics_port));
265-
warnings.push(format!("cb_pbs has an exported port on {}", metrics_port));
266-
targets.push(format!("{host_endpoint}"));
267-
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
268-
pbs_envs.insert(key, val);
269-
270-
metrics_port += 1;
269+
if metrics_config.enabled {
270+
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
271+
ports.push(format!("{}:{}", host_endpoint, metrics_port));
272+
warnings.push(format!("cb_pbs has an exported port on {}", metrics_port));
273+
targets.push(format!("{host_endpoint}"));
274+
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
275+
pbs_envs.insert(key, val);
276+
277+
metrics_port += 1;
278+
}
271279
}
272280
if log_to_file {
273281
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);
@@ -332,12 +340,15 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
332340
signer_envs.insert(key, val);
333341
}
334342
if let Some(metrics_config) = &cb_config.metrics {
335-
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
336-
ports.push(format!("{}:{}", host_endpoint, metrics_port));
337-
warnings.push(format!("cb_signer has an exported port on {}", metrics_port));
338-
targets.push(format!("{host_endpoint}"));
339-
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
340-
signer_envs.insert(key, val);
343+
if metrics_config.enabled {
344+
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
345+
ports.push(format!("{}:{}", host_endpoint, metrics_port));
346+
warnings
347+
.push(format!("cb_signer has an exported port on {}", metrics_port));
348+
targets.push(format!("{host_endpoint}"));
349+
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
350+
signer_envs.insert(key, val);
351+
}
341352
}
342353
if log_to_file {
343354
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);
@@ -457,12 +468,15 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
457468
signer_envs.insert(key, val);
458469
}
459470
if let Some(metrics_config) = &cb_config.metrics {
460-
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
461-
ports.push(format!("{}:{}", host_endpoint, metrics_port));
462-
warnings.push(format!("cb_signer has an exported port on {}", metrics_port));
463-
targets.push(format!("{host_endpoint}"));
464-
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
465-
signer_envs.insert(key, val);
471+
if metrics_config.enabled {
472+
let host_endpoint = SocketAddr::from((metrics_config.host, metrics_port));
473+
ports.push(format!("{}:{}", host_endpoint, metrics_port));
474+
warnings
475+
.push(format!("cb_signer has an exported port on {}", metrics_port));
476+
targets.push(format!("{host_endpoint}"));
477+
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
478+
signer_envs.insert(key, val);
479+
}
466480
}
467481
if log_to_file {
468482
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);

crates/common/src/config/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::utils::{default_bool, default_host, default_u16};
1010
pub struct MetricsConfig {
1111
/// Whether to collect metrics
1212
#[serde(default = "default_bool::<true>")]
13-
pub use_metrics: bool,
13+
pub enabled: bool,
1414
/// Host for metrics servers
1515
#[serde(default = "default_host")]
1616
pub host: Ipv4Addr,

docs/docs/get_started/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ port = 18550
2020
url = ""
2121

2222
[metrics]
23-
use_metrics = true
23+
enabled = true
2424
```
2525

2626
You can find a list of MEV-Boost Holesky relays [here](https://www.coincashew.com/coins/overview-eth/mev-boost/mev-relay-list#holesky-testnet-relays).
@@ -305,7 +305,7 @@ keys_path = "/path/to/keys"
305305
secrets_path = "/path/to.secrets"
306306

307307
[metrics]
308-
use_metrics = true
308+
enabled = true
309309

310310
[[modules]]
311311
id = "DA_COMMIT"

docs/docs/get_started/running/docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To start Commit-Boost run:
2323
docker compose --env-file ".cb.env" -f ".cb.docker-compose.yml" up -d
2424
```
2525

26-
This will run the all the configured services, including PBS, signer and modules (if any).
26+
This will run all the configured services, including PBS, signer and modules (if any).
2727

2828
The MEV-Boost server will be exposed at `pbs.port` from the config, `18550` in our example. You'll need to point your CL/Validator client to this port to be able to source blocks from the builder market.
2929

docs/docs/get_started/running/metrics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ description: Setup metrics collection
66

77
Commit-Boost can be configured to collect metrics from the different services and expose them to be scraped from Prometheus.
88

9-
Make use to add the `[metrics]` section to your config file:
9+
Make sure to add the `[metrics]` section to your config file:
1010

1111
```toml
1212
[metrics]
13-
use_metrics = true
13+
enabled = true
1414
```
1515
If the section is missing, metrics collection will be disabled. If you generated the `docker-compose.yml` file with `commit-boost-cli`, metrics ports will be automatically configured, and a sample `target.json` file will be created. If you're running the binaries directly, you will need to set the correct environment variables, as described in the [previous section](/get_started/running/binary#common).
1616

examples/configs/pbs_metrics.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ id = "example-relay"
1010
url = "http://0xa1cec75a3f0661e99299274182938151e8433c61a19222347ea1313d839229cb4ce4e3e5aa2bdeb71c8fcf1b084963c2@abc.xyz"
1111

1212
[metrics]
13-
use_metrics = true
13+
enabled = true
1414

1515
[logs]
1616
log_dir_path = "./logs"

0 commit comments

Comments
 (0)