From 95882bfa66370f8554038cb0ae43719f58351e75 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Wed, 20 Aug 2025 11:16:34 +1000 Subject: [PATCH] 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: https://github.com/ethpandaops/ethereum-package/pull/1160): image --- book/src/help_bn.md | 4 ++++ book/src/help_general.md | 4 ++++ book/src/help_vc.md | 4 ++++ book/src/help_vm.md | 4 ++++ book/src/help_vm_create.md | 4 ++++ book/src/help_vm_import.md | 4 ++++ book/src/help_vm_move.md | 4 ++++ lighthouse/src/main.rs | 25 ++++++++++++++++++++++++- 8 files changed, 52 insertions(+), 1 deletion(-) diff --git a/book/src/help_bn.md b/book/src/help_bn.md index 6af7b93b14..ea02b39bee 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -395,6 +395,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. --trusted-peers One or more comma-delimited trusted peer ids which always have the highest score according to the peer scoring system. diff --git a/book/src/help_general.md b/book/src/help_general.md index 2beaf78884..56e4aebdb5 100644 --- a/book/src/help_general.md +++ b/book/src/help_general.md @@ -79,6 +79,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. -V, --version Print version diff --git a/book/src/help_vc.md b/book/src/help_vc.md index ed0aaca2b1..bd6a606ff3 100644 --- a/book/src/help_vc.md +++ b/book/src/help_vc.md @@ -137,6 +137,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. --validator-registration-batch-size Defines the number of validators per validator/register_validator request sent to the BN. This value can be reduced to avoid timeouts diff --git a/book/src/help_vm.md b/book/src/help_vm.md index 206fcbf47a..409c56a74d 100644 --- a/book/src/help_vm.md +++ b/book/src/help_vm.md @@ -80,6 +80,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. Flags: --disable-log-timestamp diff --git a/book/src/help_vm_create.md b/book/src/help_vm_create.md index ff4e53849a..a438c075dc 100644 --- a/book/src/help_vm_create.md +++ b/book/src/help_vm_create.md @@ -96,6 +96,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. Flags: --disable-deposits diff --git a/book/src/help_vm_import.md b/book/src/help_vm_import.md index 9e22c4dad0..3c768f6705 100644 --- a/book/src/help_vm_import.md +++ b/book/src/help_vm_import.md @@ -76,6 +76,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. --validators-file The path to a JSON file containing a list of validators to be imported to the validator client. This file is usually named "validators.json". diff --git a/book/src/help_vm_move.md b/book/src/help_vm_move.md index 50d65d8122..cd139449b3 100644 --- a/book/src/help_vm_move.md +++ b/book/src/help_vm_move.md @@ -85,6 +85,10 @@ Options: --telemetry-collector-url URL of the OpenTelemetry collector to export tracing spans (e.g., http://localhost:4317). If not set, tracing export is disabled. + --telemetry-service-name + Override the OpenTelemetry service name. Defaults to 'lighthouse-bn' + for beacon node, 'lighthouse-vc' for validator client, or 'lighthouse' + for other subcommands. --validators The validators to be moved. Either a list of 0x-prefixed validator pubkeys or the keyword "all". diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 13029c3a15..3b0f7c3376 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -289,6 +289,20 @@ fn main() { .global(true) .display_order(0) ) + .arg( + Arg::new("telemetry-service-name") + .long("telemetry-service-name") + .value_name("NAME") + .help( + "Override the OpenTelemetry service name. \ + Defaults to 'lighthouse-bn' for beacon node, 'lighthouse-vc' for validator \ + client, or 'lighthouse' for other subcommands." + ) + .requires("telemetry-collector-url") + .action(ArgAction::Set) + .global(true) + .display_order(0) + ) .arg( Arg::new("datadir") .long("datadir") @@ -702,11 +716,20 @@ fn run( .build() .map_err(|e| format!("Failed to create OTLP exporter: {:?}", e))?; + let service_name = matches + .get_one::("telemetry-service-name") + .cloned() + .unwrap_or_else(|| match matches.subcommand() { + Some(("beacon_node", _)) => "lighthouse-bn".to_string(), + Some(("validator_client", _)) => "lighthouse-vc".to_string(), + _ => "lighthouse".to_string(), + }); + let provider = opentelemetry_sdk::trace::SdkTracerProvider::builder() .with_batch_exporter(exporter) .with_resource( opentelemetry_sdk::Resource::builder() - .with_service_name("lighthouse") + .with_service_name(service_name) .build(), ) .build();