From 9c7a1fe94db383118873c435b2221945ec2a6681 Mon Sep 17 00:00:00 2001 From: SantiagoPittella Date: Mon, 22 Sep 2025 13:40:47 -0300 Subject: [PATCH] fix: add env var to enable OTel in network monitor --- bin/network-monitor/.env | 1 + bin/network-monitor/README.md | 1 + bin/network-monitor/src/main.rs | 12 +++++++++++- bin/network-monitor/src/status.rs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/network-monitor/.env b/bin/network-monitor/.env index 4b9200f064..9d95137f73 100644 --- a/bin/network-monitor/.env +++ b/bin/network-monitor/.env @@ -1,3 +1,4 @@ MIDEN_MONITOR_RPC_URL=http://0.0.0.0:57291 MIDEN_MONITOR_REMOTE_PROVER_URLS=https://tx-prover.devnet.miden.io/,https://batch-prover.devnet.miden.io/ MIDEN_MONITOR_PORT=3001 +MIDEN_MONITOR_ENABLE_OTEL=true diff --git a/bin/network-monitor/README.md b/bin/network-monitor/README.md index b1f7438b87..7d7dc3d0ec 100644 --- a/bin/network-monitor/README.md +++ b/bin/network-monitor/README.md @@ -17,6 +17,7 @@ The monitor application uses environment variables for configuration: - `MIDEN_MONITOR_RPC_URL`: RPC service URL (default: `http://localhost:50051`) - `MIDEN_MONITOR_REMOTE_PROVER_URLS`: Comma-separated list of remote prover URLs (default: `http://localhost:50052`) - `MIDEN_MONITOR_PORT`: Web server port (default: `3000`) +- `MIDEN_MONITOR_ENABLE_OTEL`: Enable OpenTelemetry tracing (default: `false`) ## Usage diff --git a/bin/network-monitor/src/main.rs b/bin/network-monitor/src/main.rs index c79d8bf4c8..a53df03936 100644 --- a/bin/network-monitor/src/main.rs +++ b/bin/network-monitor/src/main.rs @@ -12,6 +12,8 @@ use frontend::{ServerState, serve}; use status::{MonitorConfig, ServiceStatus, run_remote_prover_status_task, run_rpc_status_task}; use tracing::info; +use crate::status::ENABLE_OTEL_ENV_VAR; + /// Component identifier for structured logging and tracing pub const COMPONENT: &str = "miden-network-monitor"; @@ -27,7 +29,15 @@ pub const COMPONENT: &str = "miden-network-monitor"; /// unexpectedly, the entire process exits. #[tokio::main] async fn main() -> anyhow::Result<()> { - miden_node_utils::logging::setup_tracing(OpenTelemetry::Disabled)?; + if std::env::var(ENABLE_OTEL_ENV_VAR) + .unwrap_or_default() + .parse::() + .unwrap_or_default() + { + miden_node_utils::logging::setup_tracing(OpenTelemetry::Enabled)?; + } else { + miden_node_utils::logging::setup_tracing(OpenTelemetry::Disabled)?; + } // Load configuration from environment variables let config = match MonitorConfig::from_env() { diff --git a/bin/network-monitor/src/status.rs b/bin/network-monitor/src/status.rs index bd2148aee0..a77746f5a2 100644 --- a/bin/network-monitor/src/status.rs +++ b/bin/network-monitor/src/status.rs @@ -34,6 +34,7 @@ const DEFAULT_PORT: u16 = 3000; const RPC_URL_ENV_VAR: &str = "MIDEN_MONITOR_RPC_URL"; const REMOTE_PROVER_URLS_ENV_VAR: &str = "MIDEN_MONITOR_REMOTE_PROVER_URLS"; const PORT_ENV_VAR: &str = "MIDEN_MONITOR_PORT"; +pub(crate) const ENABLE_OTEL_ENV_VAR: &str = "MIDEN_MONITOR_ENABLE_OTEL"; /// Configuration for the monitor. ///