Skip to content

Commit 95882bf

Browse files
authored
Add --telemetry-service-name CLI flag for OpenTelemetry service name override (#7903)
Allows users to customize the OpenTelemetry service name instead of using the hardcoded default `lighthouse`. Defaults to 'lighthouse-bn' for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' for other subcommands. This is useful when analysing traces from multiple nodes, see Grafana screenshot below with service name overrides in Kurtosis (`ethereum-package` PR: ethpandaops/ethereum-package#1160): <img width="1148" height="627" alt="image" src="https://github.com/user-attachments/assets/7e875639-10f7-4756-837f-2006fa4b12e0" />
1 parent 34dd1b2 commit 95882bf

File tree

8 files changed

+52
-1
lines changed

8 files changed

+52
-1
lines changed

book/src/help_bn.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ Options:
395395
--telemetry-collector-url <URL>
396396
URL of the OpenTelemetry collector to export tracing spans (e.g.,
397397
http://localhost:4317). If not set, tracing export is disabled.
398+
--telemetry-service-name <NAME>
399+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
400+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
401+
for other subcommands.
398402
--trusted-peers <TRUSTED_PEERS>
399403
One or more comma-delimited trusted peer ids which always have the
400404
highest score according to the peer scoring system.

book/src/help_general.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Options:
7979
--telemetry-collector-url <URL>
8080
URL of the OpenTelemetry collector to export tracing spans (e.g.,
8181
http://localhost:4317). If not set, tracing export is disabled.
82+
--telemetry-service-name <NAME>
83+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
84+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
85+
for other subcommands.
8286
-V, --version
8387
Print version
8488

book/src/help_vc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ Options:
137137
--telemetry-collector-url <URL>
138138
URL of the OpenTelemetry collector to export tracing spans (e.g.,
139139
http://localhost:4317). If not set, tracing export is disabled.
140+
--telemetry-service-name <NAME>
141+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
142+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
143+
for other subcommands.
140144
--validator-registration-batch-size <INTEGER>
141145
Defines the number of validators per validator/register_validator
142146
request sent to the BN. This value can be reduced to avoid timeouts

book/src/help_vm.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ Options:
8080
--telemetry-collector-url <URL>
8181
URL of the OpenTelemetry collector to export tracing spans (e.g.,
8282
http://localhost:4317). If not set, tracing export is disabled.
83+
--telemetry-service-name <NAME>
84+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
85+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
86+
for other subcommands.
8387
8488
Flags:
8589
--disable-log-timestamp

book/src/help_vm_create.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ Options:
9696
--telemetry-collector-url <URL>
9797
URL of the OpenTelemetry collector to export tracing spans (e.g.,
9898
http://localhost:4317). If not set, tracing export is disabled.
99+
--telemetry-service-name <NAME>
100+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
101+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
102+
for other subcommands.
99103
100104
Flags:
101105
--disable-deposits

book/src/help_vm_import.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Options:
7676
--telemetry-collector-url <URL>
7777
URL of the OpenTelemetry collector to export tracing spans (e.g.,
7878
http://localhost:4317). If not set, tracing export is disabled.
79+
--telemetry-service-name <NAME>
80+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
81+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
82+
for other subcommands.
7983
--validators-file <PATH_TO_JSON_FILE>
8084
The path to a JSON file containing a list of validators to be imported
8185
to the validator client. This file is usually named "validators.json".

book/src/help_vm_move.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ Options:
8585
--telemetry-collector-url <URL>
8686
URL of the OpenTelemetry collector to export tracing spans (e.g.,
8787
http://localhost:4317). If not set, tracing export is disabled.
88+
--telemetry-service-name <NAME>
89+
Override the OpenTelemetry service name. Defaults to 'lighthouse-bn'
90+
for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse'
91+
for other subcommands.
8892
--validators <STRING>
8993
The validators to be moved. Either a list of 0x-prefixed validator
9094
pubkeys or the keyword "all".

lighthouse/src/main.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@ fn main() {
289289
.global(true)
290290
.display_order(0)
291291
)
292+
.arg(
293+
Arg::new("telemetry-service-name")
294+
.long("telemetry-service-name")
295+
.value_name("NAME")
296+
.help(
297+
"Override the OpenTelemetry service name. \
298+
Defaults to 'lighthouse-bn' for beacon node, 'lighthouse-vc' for validator \
299+
client, or 'lighthouse' for other subcommands."
300+
)
301+
.requires("telemetry-collector-url")
302+
.action(ArgAction::Set)
303+
.global(true)
304+
.display_order(0)
305+
)
292306
.arg(
293307
Arg::new("datadir")
294308
.long("datadir")
@@ -702,11 +716,20 @@ fn run<E: EthSpec>(
702716
.build()
703717
.map_err(|e| format!("Failed to create OTLP exporter: {:?}", e))?;
704718

719+
let service_name = matches
720+
.get_one::<String>("telemetry-service-name")
721+
.cloned()
722+
.unwrap_or_else(|| match matches.subcommand() {
723+
Some(("beacon_node", _)) => "lighthouse-bn".to_string(),
724+
Some(("validator_client", _)) => "lighthouse-vc".to_string(),
725+
_ => "lighthouse".to_string(),
726+
});
727+
705728
let provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
706729
.with_batch_exporter(exporter)
707730
.with_resource(
708731
opentelemetry_sdk::Resource::builder()
709-
.with_service_name("lighthouse")
732+
.with_service_name(service_name)
710733
.build(),
711734
)
712735
.build();

0 commit comments

Comments
 (0)