From 10e72df3318c7140d7cb0605e2af1f19119ceab9 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Wed, 3 Sep 2025 18:05:09 +1000 Subject: [PATCH] Add `tls-roots` feature to `opentelemetry_otlp` to support exporting traces over https (#7987) --- Cargo.lock | 64 ++++++++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- lighthouse/src/main.rs | 4 ++- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4020d9611f..96768211eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1809,6 +1809,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -2152,7 +2162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18e4fdb82bd54a12e42fb58a800dcae6b9e13982238ce2296dc3570b92148e1f" dependencies = [ "data-encoding", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] @@ -4642,7 +4652,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdf9d64cfcf380606e64f9a0bcf493616b65331199f984151a6fa11a7b3cde38" dependencies = [ "async-io", - "core-foundation", + "core-foundation 0.9.4", "fnv", "futures", "if-addrs", @@ -5097,9 +5107,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libloading" @@ -6199,7 +6209,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -8123,6 +8133,7 @@ version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ + "log", "once_cell", "ring", "rustls-pki-types", @@ -8131,6 +8142,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework 3.3.0", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -8380,7 +8403,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.9.0", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80fb1d92c5028aa318b4b8bd7302a5bfcf48be96a37fc6fc790f806b0004ee0c" +dependencies = [ + "bitflags 2.9.0", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -9103,7 +9139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys 0.5.0", ] @@ -9114,7 +9150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags 2.9.0", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys 0.6.0", ] @@ -9473,6 +9509,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls 0.23.23", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.17" @@ -9576,7 +9622,9 @@ dependencies = [ "percent-encoding", "pin-project", "prost", + "rustls-native-certs", "tokio", + "tokio-rustls 0.26.2", "tokio-stream", "tower 0.5.2", "tower-layer", diff --git a/Cargo.toml b/Cargo.toml index c08e7c59a0..ca5f7bc153 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -198,7 +198,7 @@ node_test_rig = { path = "testing/node_test_rig" } num_cpus = "1" once_cell = "1.17.1" opentelemetry = "0.30.0" -opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic"] } +opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic", "tls-roots"] } opentelemetry_sdk = "0.30.0" operation_pool = { path = "beacon_node/operation_pool" } parking_lot = "0.12" diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 3b0f7c3376..8660074e91 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -20,7 +20,8 @@ use lighthouse_version::VERSION; use logging::{MetricsLayer, build_workspace_filter, crit}; use malloc_utils::configure_memory_allocator; use opentelemetry::trace::TracerProvider; -use opentelemetry_otlp::WithExportConfig; +use opentelemetry_otlp::tonic_types::transport::ClientTlsConfig; +use opentelemetry_otlp::{WithExportConfig, WithTonicConfig}; use std::backtrace::Backtrace; use std::io::IsTerminal; use std::path::PathBuf; @@ -712,6 +713,7 @@ fn run( let telemetry_layer = environment.runtime().block_on(async { let exporter = opentelemetry_otlp::SpanExporter::builder() .with_tonic() + .with_tls_config(ClientTlsConfig::new().with_native_roots()) .with_endpoint(telemetry_collector_url) .build() .map_err(|e| format!("Failed to create OTLP exporter: {:?}", e))?;