diff --git a/Cargo.lock b/Cargo.lock index 66e714a..cbf3669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1680,7 +1680,7 @@ dependencies = [ "p3-miden-lifted-stark", "p3-symmetric", "p3-util", - "rand 0.9.2", + "rand 0.9.4", "rand_chacha", "rand_core 0.9.5", "rand_hc", @@ -1815,7 +1815,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry_sdk", "prost-types", - "rand 0.9.2", + "rand 0.9.4", "serial_test", "thiserror", "tokio", @@ -1932,7 +1932,7 @@ dependencies = [ "miden-protocol-macros", "miden-utils-sync", "miden-verifier", - "rand 0.9.2", + "rand 0.9.4", "rand_chacha", "rand_xoshiro", "regex", @@ -2306,7 +2306,7 @@ dependencies = [ "futures-util", "opentelemetry", "percent-encoding", - "rand 0.9.2", + "rand 0.9.4", "serde_json", "thiserror", "tokio", @@ -2822,7 +2822,7 @@ checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" dependencies = [ "bitflags", "num-traits", - "rand 0.9.2", + "rand 0.9.4", "rand_chacha", "rand_xorshift", "regex-syntax", @@ -3012,9 +3012,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ "rand_chacha", "rand_core 0.9.5", diff --git a/Cargo.toml b/Cargo.toml index 643f113..972d387 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ anyhow = { default-features = false, version = "1.0" } async-trait = { version = "0.1" } base64 = { version = "0.22" } chrono = { features = ["serde"], version = "0.4" } -clap = { features = ["derive"], version = "4.5" } +clap = { features = ["derive", "env"], version = "4.5" } deadpool = { default-features = false, features = ["managed", "rt_tokio_1"], version = "0.12" } deadpool-sync = { version = "0.1" } fs-err = { version = "3" } diff --git a/bin/node/docker/docker-compose.yml b/bin/node/docker/docker-compose.yml index 9b1505d..8d5c57c 100644 --- a/bin/node/docker/docker-compose.yml +++ b/bin/node/docker/docker-compose.yml @@ -8,9 +8,9 @@ services: - "57292:57292" # gRPC - "9091:9090" # Health checks environment: - - OTEL_ENABLED=true + - MIDEN_TLNODE_ENABLE_OTEL=true - JSON_LOGGING=true - - OTEL_TRACES_ENDPOINT=http://otel-collector:4317 + - MIDEN_TLNODE_OTEL_ENDPOINT=http://otel-collector:4317 - OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf - OTEL_SERVICE_NAME=miden-note-transport-node - RUST_LOG=INFO diff --git a/bin/node/src/main.rs b/bin/node/src/main.rs index cc4a340..d160309 100644 --- a/bin/node/src/main.rs +++ b/bin/node/src/main.rs @@ -36,6 +36,18 @@ struct Args { /// Connection timeout in seconds #[arg(long, default_value = "4")] request_timeout: usize, + + /// Enable OpenTelemetry tracing and metrics export + #[arg(long, env = "MIDEN_TLNODE_ENABLE_OTEL", default_value = "false")] + enable_otel: bool, + + /// OpenTelemetry OTLP endpoint + #[arg( + long, + env = "MIDEN_TLNODE_OTEL_ENDPOINT", + default_value = "http://localhost:4317" + )] + otel_endpoint: String, } #[tokio::main] @@ -44,7 +56,7 @@ async fn main() -> Result<()> { let args = Args::parse(); // Setup tracing - let tracing_cfg = TracingConfig::from_env(); + let tracing_cfg = TracingConfig::new(args.enable_otel, args.otel_endpoint.clone()); setup_tracing(tracing_cfg.clone())?; info!("Starting Miden Transport Node..."); diff --git a/crates/node/src/logging.rs b/crates/node/src/logging.rs index d04eaa4..d47c362 100644 --- a/crates/node/src/logging.rs +++ b/crates/node/src/logging.rs @@ -33,22 +33,12 @@ pub enum OpenTelemetry { } impl TracingConfig { - /// Tracing configuration constructor using environment variables - pub fn from_env() -> Self { - let otel = { - let otel_enabled = std::env::var("OTEL_ENABLED") - .unwrap_or_else(|_| "false".to_string()) - .parse() - .unwrap_or(false); - if otel_enabled { - OpenTelemetry::Enabled { - endpoint: std::env::var("OTEL_TRACES_ENDPOINT") - .ok() - .unwrap_or("http://localhost:4317".to_string()), - } - } else { - OpenTelemetry::Disabled - } + /// Create a new tracing configuration with explicit parameters. + pub fn new(enable_otel: bool, otel_endpoint: String) -> Self { + let otel = if enable_otel { + OpenTelemetry::Enabled { endpoint: otel_endpoint } + } else { + OpenTelemetry::Disabled }; TracingConfig { diff --git a/deny.toml b/deny.toml index 3082ab7..18e1cf4 100644 --- a/deny.toml +++ b/deny.toml @@ -43,7 +43,9 @@ allow = [ "FTL", "ISC", "JSON", + "LGPL-3.0-or-later", "MIT", + "MPL-2.0", "MS-PL", "OpenSSL", "PostgreSQL",