diff --git a/Cargo.lock b/Cargo.lock index 8463b149f5..fdd308eb6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5936,6 +5936,7 @@ dependencies = [ "colored", "futures", "mime", + "nym-bin-common", "serde", "serde_json", "serde_yaml", @@ -6906,6 +6907,7 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.16", + "tracing", ] [[package]] diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index 9ac6a9ae3a..d11e8f994b 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -46,7 +46,6 @@ nym-bandwidth-controller = { path = "../../common/bandwidth-controller" } nym-bin-common = { path = "../../common/bin-common", features = [ "output_format", "clap", - "basic_tracing", ] } nym-client-core = { path = "../../common/client-core", features = [ "fs-credentials-storage", diff --git a/clients/native/src/main.rs b/clients/native/src/main.rs index d00f0b5e51..5603606e26 100644 --- a/clients/native/src/main.rs +++ b/clients/native/src/main.rs @@ -4,7 +4,7 @@ use std::error::Error; use clap::{crate_name, crate_version, Parser}; -use nym_bin_common::logging::{maybe_print_banner, setup_tracing_logger}; +use nym_bin_common::logging::{maybe_print_banner, setup_no_otel_logger}; use nym_network_defaults::setup_env; pub mod client; @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { if !args.no_banner { maybe_print_banner(crate_name!(), crate_version!()); } - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); if let Err(err) = commands::execute(args).await { log::error!("{err}"); diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index e2ed20d193..f1aa93f0fb 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -27,7 +27,6 @@ zeroize = { workspace = true } nym-bin-common = { path = "../../common/bin-common", features = [ "output_format", "clap", - "basic_tracing", ] } nym-client-core = { path = "../../common/client-core", features = [ "fs-credentials-storage", diff --git a/clients/socks5/src/main.rs b/clients/socks5/src/main.rs index 36161d3dcd..5936972515 100644 --- a/clients/socks5/src/main.rs +++ b/clients/socks5/src/main.rs @@ -4,7 +4,7 @@ use std::error::Error; use clap::{crate_name, crate_version, Parser}; -use nym_bin_common::logging::{maybe_print_banner, setup_tracing_logger}; +use nym_bin_common::logging::{maybe_print_banner, setup_no_otel_logger}; use nym_network_defaults::setup_env; mod commands; @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box> { if !args.no_banner { maybe_print_banner(crate_name!(), crate_version!()); } - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); if let Err(err) = commands::execute(args).await { log::error!("{err}"); diff --git a/common/bin-common/Cargo.toml b/common/bin-common/Cargo.toml index 7da4c7a55c..8ebf4407c7 100644 --- a/common/bin-common/Cargo.toml +++ b/common/bin-common/Cargo.toml @@ -25,42 +25,33 @@ schemars = { workspace = true, features = ["preserve_order"], optional = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, optional = true } thiserror = { workspace = true } -tracing = { workspace = true, optional = true } -tracing-core = { workspace = true, optional = true } +tracing = { workspace = true } +tracing-core = { workspace = true } tracing-opentelemetry = { workspace = true, optional = true } -tracing-serde = { workspace = true, optional = true } -tracing-subscriber = { workspace = true, features = ["env-filter", "json"], optional = true } -tracing-tree = { workspace = true, optional = true } +tracing-serde = { workspace = true } +tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } +tracing-tree = { workspace = true } utoipa = { workspace = true, optional = true } [build-dependencies] vergen = { workspace = true, features = ["build", "git", "gitcl", "rustc", "cargo"] } [features] -default = ["otel"] # 🚨🚨🚨 TODO: remove otel as a default feature 🚨🚨🚨 +default = [] openapi = ["utoipa"] output_format = ["serde_json", "dep:clap"] bin_info_schema = ["schemars"] -basic_tracing = ["dep:tracing", "tracing-subscriber"] -tokio-console = ["dep:tracing", "tracing-subscriber"] -tracing = [ - "basic_tracing", - "chrono", - "serde_json", - "tracing-core", - "tracing-opentelemetry", - "tracing-serde", - "tracing-subscriber", - "tracing-tree", -] +tokio-console = ["otel"] otel = [ + "chrono", + "tracing-opentelemetry", "opentelemetry", "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry-stdout", "opentelemetry_sdk", + "serde_json", "rand", - "tracing", ] clap = ["dep:clap", "dep:clap_complete", "dep:clap_complete_fig"] models = [] diff --git a/common/bin-common/src/lib.rs b/common/bin-common/src/lib.rs index dbeb462615..df22695b21 100644 --- a/common/bin-common/src/lib.rs +++ b/common/bin-common/src/lib.rs @@ -4,6 +4,7 @@ pub mod build_information; pub mod logging; +#[cfg(feature = "otel")] pub mod opentelemetry; #[cfg(feature = "clap")] diff --git a/common/bin-common/src/opentelemetry/error.rs b/common/bin-common/src/logging/error.rs similarity index 88% rename from common/bin-common/src/opentelemetry/error.rs rename to common/bin-common/src/logging/error.rs index c8875eb2fb..e9ea26c847 100644 --- a/common/bin-common/src/opentelemetry/error.rs +++ b/common/bin-common/src/logging/error.rs @@ -1,6 +1,6 @@ // Copyright 2025 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 - +#[cfg(feature = "otel")] use opentelemetry_otlp::ExporterBuildError; #[derive(thiserror::Error, Debug)] @@ -8,11 +8,10 @@ pub enum TracingError { #[error("tracing logger already initialised")] TracingLoggerAlreadyInitialised, - // #[error("I/O error: {0}")] - // IoError(#[from] std::io::Error), #[error("Logging error: {0}")] TracingTryInitError(tracing_subscriber::util::TryInitError), + #[cfg(feature = "otel")] #[error("{0}")] TracingExporterBuildError(#[from] ExporterBuildError), diff --git a/common/bin-common/src/logging/mod.rs b/common/bin-common/src/logging/mod.rs index eabeb5445a..589f03678e 100644 --- a/common/bin-common/src/logging/mod.rs +++ b/common/bin-common/src/logging/mod.rs @@ -1,8 +1,12 @@ // Copyright 2022-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +pub mod error; + +use error::TracingError; use serde::{Deserialize, Serialize}; use std::io::IsTerminal; +use tracing_subscriber::{filter::Directive, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug, Default, Copy, Clone, Deserialize, PartialEq, Eq, Serialize)] #[serde(deny_unknown_fields)] @@ -11,7 +15,6 @@ pub struct LoggingSettings { } // don't call init so that we could attach additional layers -#[cfg(feature = "basic_tracing")] pub fn build_tracing_logger() -> impl tracing_subscriber::layer::SubscriberExt { use tracing_subscriber::prelude::*; @@ -20,7 +23,6 @@ pub fn build_tracing_logger() -> impl tracing_subscriber::layer::SubscriberExt { .with(default_tracing_env_filter()) } -#[cfg(feature = "basic_tracing")] pub fn default_tracing_env_filter() -> tracing_subscriber::filter::EnvFilter { if ::std::env::var("RUST_LOG").is_ok() { tracing_subscriber::filter::EnvFilter::from_default_env() @@ -32,7 +34,6 @@ pub fn default_tracing_env_filter() -> tracing_subscriber::filter::EnvFilter { } } -#[cfg(feature = "basic_tracing")] pub fn default_tracing_fmt_layer( writer: W, ) -> impl tracing_subscriber::Layer + Sync + Send + 'static @@ -52,18 +53,47 @@ where .with_target(false) } -#[cfg(feature = "basic_tracing")] -pub fn setup_tracing_logger() { - use tracing_subscriber::util::SubscriberInitExt; - build_tracing_logger().init() +/// Creates a tracing filter that sets more granular log levels for specific crates. +/// This allows for finer control over logging verbosity. +pub(crate) fn granual_filtered_env() -> Result +{ + fn directive_checked(directive: impl Into) -> Result { + directive.into().parse().map_err(From::from) + } + + let mut filter = default_tracing_env_filter(); + + // these crates are more granularly filtered + let filter_crates = ["defguard_wireguard_rs"]; + for crate_name in filter_crates { + filter = filter.add_directive(directive_checked(format!("{crate_name}=warn"))?); + } + Ok(filter) +} + +pub fn setup_no_otel_logger() -> Result<(), TracingError> { + // Only set up if not already initialized + if tracing::dispatcher::has_been_set() { + // It shouldn't be - this is really checking that it is torn down between async command executions + return Err(TracingError::TracingLoggerAlreadyInitialised); + } + + let registry = tracing_subscriber::registry() + .with(default_tracing_fmt_layer(std::io::stderr)) + .with(granual_filtered_env()?); + + registry + .try_init() + .map_err(|e| TracingError::TracingTryInitError(e))?; + + Ok(()) } // TODO: This has to be a macro, running it as a function does not work for the file_appender for some reason -#[cfg(feature = "tracing")] #[macro_export] macro_rules! setup_tracing { ($service_name: expr) => { - crate::opentelemetry::setup_no_otel_logger() + setup_no_otel_logger() }; } diff --git a/common/bin-common/src/opentelemetry/mod.rs b/common/bin-common/src/opentelemetry/mod.rs index e6dd8cde59..500b40bbf4 100644 --- a/common/bin-common/src/opentelemetry/mod.rs +++ b/common/bin-common/src/opentelemetry/mod.rs @@ -1,5 +1,4 @@ pub mod context; -pub mod error; pub mod compact_id_generator; mod trace_id_format; @@ -9,8 +8,8 @@ use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::fmt; -use crate::logging::{default_tracing_env_filter, default_tracing_fmt_layer}; -use crate::opentelemetry::error::TracingError; +use crate::logging::default_tracing_env_filter; +use crate::logging::error::TracingError; use crate::opentelemetry::compact_id_generator::Compact13BytesIdGenerator; use opentelemetry::trace::TracerProvider; use opentelemetry::{global, KeyValue}; @@ -54,10 +53,10 @@ pub(crate) fn granual_filtered_env() -> Result Result { +pub fn setup_tracing_logger(service_name: String) -> Result<(), TracingError> { if tracing::dispatcher::has_been_set() { // It shouldn't be - this is really checking that it is torn down between async command executions - return Err(error::TracingError::TracingLoggerAlreadyInitialised); + return Err(TracingError::TracingLoggerAlreadyInitialised); } let key = @@ -103,29 +102,6 @@ pub fn setup_tracing_logger(service_name: String) -> Result Result<(), TracingError> { - // Only set up if not already initialized - if tracing::dispatcher::has_been_set() { - // It shouldn't be - this is really checking that it is torn down between async command executions - return Err(TracingError::TracingLoggerAlreadyInitialised); - } - - let registry = tracing_subscriber::registry() - .with(default_tracing_fmt_layer(std::io::stderr)) - .with(granual_filtered_env()?) - .with(tracing_subscriber::filter::LevelFilter::from_level( - Level::INFO, - )); - - registry - .try_init() - .map_err(|e| TracingError::TracingTryInitError(e))?; - Ok(()) } diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index badd44beaf..e30652520c 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -99,6 +99,7 @@ pub struct ClientOutput { } impl ClientOutput { + #[instrument(name = "ClientOutput::register_receiver", skip_all)] pub fn register_receiver( &mut self, ) -> Result>, ClientCoreError> { diff --git a/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs b/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs index a7d15b67fe..dfd9192f18 100644 --- a/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs +++ b/common/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs @@ -70,6 +70,7 @@ where .send_reply(recipient_tag, data, lane, max_retransmissions); } + #[instrument(skip_all)] async fn handle_plain_message( &mut self, recipient: Recipient, @@ -88,6 +89,7 @@ where } } + #[instrument(skip_all)] async fn handle_repliable_message( &mut self, recipient: Recipient, @@ -234,6 +236,7 @@ where }; } + #[instrument(skip_all)] pub(crate) async fn run(&mut self, shutdown_token: ShutdownToken) { debug!("Started InputMessageListener with graceful shutdown support"); diff --git a/common/client-core/src/client/real_messages_control/message_handler.rs b/common/client-core/src/client/real_messages_control/message_handler.rs index 6238f2ce6c..3bc52225c0 100644 --- a/common/client-core/src/client/real_messages_control/message_handler.rs +++ b/common/client-core/src/client/real_messages_control/message_handler.rs @@ -27,7 +27,7 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; use thiserror::Error; -use tracing::{debug, error, info, trace, warn}; +use tracing::{debug, error, info, instrument, trace, warn}; // TODO: move that error elsewhere since it seems to be contaminating different files #[derive(Debug, Error)] @@ -476,6 +476,7 @@ where self.forward_messages(msgs, lane).await; } + #[instrument(skip_all)] pub(crate) async fn try_send_plain_message( &mut self, recipient: Recipient, @@ -497,6 +498,7 @@ where .await } + #[instrument(skip_all)] pub(crate) async fn try_split_and_send_non_reply_message( &mut self, message: NymMessage, diff --git a/common/gateway-requests/Cargo.toml b/common/gateway-requests/Cargo.toml index 6067b551d2..682a4a485f 100644 --- a/common/gateway-requests/Cargo.toml +++ b/common/gateway-requests/Cargo.toml @@ -35,8 +35,8 @@ nym-credentials = { path = "../credentials" } nym-credentials-interface = { path = "../credentials-interface" } opentelemetry = { workspace = true, features = ["trace"], optional = true } -opentelemetry_sdk = { workspace = true } -tracing = { workspace = true, features = ["std", "attributes", "tracing-attributes"], optional = true } +opentelemetry_sdk = { workspace = true, optional = true } +tracing = { workspace = true, features = ["std", "attributes", "tracing-attributes"] } [target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio] workspace = true @@ -57,8 +57,9 @@ nym-test-utils = { path = "../test-utils" } tokio = { workspace = true, features = ["full"] } [features] -default = ["otel"] # 🚨🚨🚨 TODO: remove otel as a default feature 🚨🚨🚨 +default = [] otel = [ + "nym-bin-common/otel", "opentelemetry", - "tracing" + "opentelemetry_sdk", ] diff --git a/common/gateway-requests/src/types/text_request/mod.rs b/common/gateway-requests/src/types/text_request/mod.rs index 9bf89c52fe..08f7af6df4 100644 --- a/common/gateway-requests/src/types/text_request/mod.rs +++ b/common/gateway-requests/src/types/text_request/mod.rs @@ -8,6 +8,7 @@ use crate::{ AUTHENTICATE_V2_PROTOCOL_VERSION, CREDENTIAL_UPDATE_V2_PROTOCOL_VERSION, INITIAL_PROTOCOL_VERSION, }; +#[cfg(feature = "otel")] use nym_bin_common::opentelemetry::context::ContextCarrier; use nym_credentials_interface::CredentialSpendingData; use nym_crypto::asymmetric::ed25519; @@ -135,15 +136,21 @@ impl ClientControlRequest { let nonce = shared_key.random_nonce_or_iv(); let ciphertext = shared_key.encrypt_naive(address.as_bytes_ref(), Some(&nonce))?; - let context = opentelemetry::Context::current(); - let context_carrier = ContextCarrier::new_with_current_context(context).into_map(); + #[cfg(feature = "otel")] + let context_carrier = { + let context = opentelemetry::Context::current(); + ContextCarrier::new_with_current_context(context).into_map() + }; Ok(ClientControlRequest::Authenticate { protocol_version, address: address.as_base58_string(), enc_address: bs58::encode(&ciphertext).into_string(), iv: bs58::encode(&nonce).into_string(), + #[cfg(feature = "otel")] otel_context: Some(context_carrier), + #[cfg(not(feature = "otel"))] + otel_context: None, }) } @@ -155,8 +162,13 @@ impl ClientControlRequest { // if we're using v2 authentication, we must announce at least that protocol version let protocol_version = AUTHENTICATE_V2_PROTOCOL_VERSION; - let otel_context = opentelemetry::Context::current(); - let context_carrier = ContextCarrier::new_with_current_context(otel_context).into_map(); + #[cfg(feature = "otel")] + let context_carrier = { + let otel_context = opentelemetry::Context::current(); + ContextCarrier::new_with_current_context(otel_context).into_map() + }; + #[cfg(not(feature = "otel"))] + let context_carrier = None; Ok(ClientControlRequest::AuthenticateV2(Box::new( AuthenticateRequest::new( diff --git a/common/http-api-client/Cargo.toml b/common/http-api-client/Cargo.toml index e41f4cdf00..52d3ab6f52 100644 --- a/common/http-api-client/Cargo.toml +++ b/common/http-api-client/Cargo.toml @@ -12,8 +12,7 @@ license.workspace = true [features] # TODO: Remove otel from default before release -# Opentelemetry should remain an opt-in for debug purposes only -default=["tunneling", "otel"] +default=["tunneling"] tunneling=[] network-defaults = ["dep:nym-network-defaults"] otel = ["nym-bin-common/otel", "opentelemetry", "opentelemetry_sdk"] @@ -58,4 +57,3 @@ features = ["tokio"] [dev-dependencies] tokio = { workspace = true, features = ["rt", "macros"] } - diff --git a/common/http-api-client/src/lib.rs b/common/http-api-client/src/lib.rs index a63d39ddde..4114760203 100644 --- a/common/http-api-client/src/lib.rs +++ b/common/http-api-client/src/lib.rs @@ -977,16 +977,18 @@ impl ApiClientCore for Client { self.apply_hosts_to_req(&mut req); // if opentelemetry is activated add the current trace context to the request - // TODO featurize opentelemetry - use opentelemetry::Context; - use nym_bin_common::opentelemetry::context::ContextCarrier; + #[cfg(feature = "otel")] + { + use opentelemetry::Context; + use nym_bin_common::opentelemetry::context::ContextCarrier; - let carrier = ContextCarrier::new_with_current_context(Context::current()); + let carrier = ContextCarrier::new_with_current_context(Context::current()); - if let Some(traceparent) = carrier.extract_traceparent() { - if let Ok(header_value) = HeaderValue::from_str(&traceparent) { - req.headers_mut() - .insert("traceparent", header_value); + if let Some(traceparent) = carrier.extract_traceparent() { + if let Ok(header_value) = HeaderValue::from_str(&traceparent) { + req.headers_mut() + .insert("traceparent", header_value); + } } } diff --git a/common/http-api-common/Cargo.toml b/common/http-api-common/Cargo.toml index 4a405c155e..c9cf367fad 100644 --- a/common/http-api-common/Cargo.toml +++ b/common/http-api-common/Cargo.toml @@ -18,6 +18,7 @@ bytes = { workspace = true, optional = true } colored = { workspace = true, optional = true } futures = { workspace = true, optional = true } mime = { workspace = true, optional = true } +nym-bin-common = { path = "../bin-common" } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } serde_yaml = { workspace = true, optional = true } @@ -49,6 +50,8 @@ middleware = [ "zeroize" ] +otel = ["nym-bin-common/otel"] + utoipa = ["dep:utoipa"] [lints] diff --git a/common/http-api-common/src/middleware/logging.rs b/common/http-api-common/src/middleware/logging.rs index 0446ded786..b79d0a6b2e 100644 --- a/common/http-api-common/src/middleware/logging.rs +++ b/common/http-api-common/src/middleware/logging.rs @@ -57,12 +57,15 @@ async fn log_request( let host = header_map(request.headers().get(HOST), "Unknown Host".to_string()); // Extract traceparent from headers if it exists + #[cfg(feature = "otel")] let traceparent = request .headers() .get("traceparent") .and_then(|h| h.to_str().ok()) .map(|s| s.to_string()); - + #[cfg(not(feature = "otel"))] + let traceparent: Option = None; + let start = Instant::now(); // run request through all middleware, incl. extractors let res = next.run(request).await; @@ -89,7 +92,7 @@ async fn log_request( match level { LogLevel::Debug => debug!( - "[{addr} -> {host}] {method} '{uri}': {print_status} {time_taken} {agent_str}: {agent} traceparent: {traceparent:?}" + "[{addr} -> {host}] {method} '{uri}': {print_status} {time_taken} {agent_str}: {agent} traceparent: {traceparent:?}", ), LogLevel::Info => info!( "[{addr} -> {host}] {method} '{uri}': {print_status} {time_taken} {agent_str}: {agent} traceparent: {traceparent:?}" diff --git a/common/nymsphinx/Cargo.toml b/common/nymsphinx/Cargo.toml index 20d7e29552..b37c5c613c 100644 --- a/common/nymsphinx/Cargo.toml +++ b/common/nymsphinx/Cargo.toml @@ -57,3 +57,7 @@ outfox = [ "nym-sphinx-params/outfox", "nym-sphinx-types/outfox", ] + +otel = [ + "nym-bin-common/otel", +] \ No newline at end of file diff --git a/common/nymsphinx/addressing/Cargo.toml b/common/nymsphinx/addressing/Cargo.toml index 09042e3793..f3252b212a 100644 --- a/common/nymsphinx/addressing/Cargo.toml +++ b/common/nymsphinx/addressing/Cargo.toml @@ -13,10 +13,15 @@ nym-crypto = { path = "../../crypto", features = ["asymmetric", "sphinx"] } # al nym-sphinx-types = { path = "../types", features = ["sphinx"] } # we need to be able to refer to some types defined inside sphinx crate serde = { workspace = true } # implementing serialization/deserialization for some types, like `Recipient` thiserror = { workspace = true } +tracing = { workspace = true } [dev-dependencies] rand = { workspace = true } nym-crypto = { path = "../../crypto", features = ["rand"] } bincode = { workspace = true } serde_json = { workspace = true } -serde = { workspace = true, features = ["derive"] } \ No newline at end of file +serde = { workspace = true, features = ["derive"] } + +[features] +default = [] +otel = ["nym-bin-common/otel"] \ No newline at end of file diff --git a/common/nymsphinx/addressing/src/clients.rs b/common/nymsphinx/addressing/src/clients.rs index fe439cebe4..0ffafafe97 100644 --- a/common/nymsphinx/addressing/src/clients.rs +++ b/common/nymsphinx/addressing/src/clients.rs @@ -151,12 +151,19 @@ impl Recipient { // it shouldn't be? Maybe it should be (for example) H(`ClientIdentity || ClientEncryptionKey`) // instead? That is an open question. pub fn as_sphinx_destination(&self, trace_id: Option<[u8; 12]>) -> Destination { + #[cfg(feature = "otel")] use nym_bin_common::opentelemetry::compact_id_generator::decompress_trace_id; + #[cfg(feature = "otel")] let trace_id_16 = if let Some(trace_id) = trace_id { decompress_trace_id(&trace_id) } else { decompress_trace_id(&[0u8; 12]) }; + #[cfg(not(feature = "otel"))] + let trace_id_16 = { + _ = trace_id; + [0u8; 16] + }; // since the nym mix network differs slightly in design from loopix, we do not care // about "surb_id" field at all and just use the default value. diff --git a/common/nymsphinx/framing/Cargo.toml b/common/nymsphinx/framing/Cargo.toml index f1021a7be2..cca60a9920 100644 --- a/common/nymsphinx/framing/Cargo.toml +++ b/common/nymsphinx/framing/Cargo.toml @@ -23,3 +23,7 @@ nym-sphinx-acknowledgements = { path = "../acknowledgements" } [dev-dependencies] tokio = { workspace = true, features = ["full"] } + +[features] +default = [] +otel = ["nym-bin-common/otel"] \ No newline at end of file diff --git a/common/nymsphinx/framing/src/processing.rs b/common/nymsphinx/framing/src/processing.rs index 43f1a73cb1..fa164be38d 100644 --- a/common/nymsphinx/framing/src/processing.rs +++ b/common/nymsphinx/framing/src/processing.rs @@ -2,8 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 use crate::packet::FramedNymPacket; -use nym_bin_common::opentelemetry::compact_id_generator::decompress_trace_id; -use nym_bin_common::opentelemetry::context::ManualContextPropagator; +#[cfg(feature = "otel")] +use nym_bin_common::opentelemetry::{ + compact_id_generator::decompress_trace_id, + context::ManualContextPropagator, +}; + use nym_sphinx_acknowledgements::surb_ack::{SurbAck, SurbAckRecoveryError}; use nym_sphinx_addressing::nodes::{NymNodeRoutingAddress, NymNodeRoutingAddressError}; use nym_sphinx_forwarding::packet::MixPacket; @@ -16,7 +20,9 @@ use nym_sphinx_types::{ }; use std::fmt::Display; use thiserror::Error; -use tracing::{debug, error, info, instrument, trace, warn, warn_span}; +use tracing::{debug, error, info, instrument, trace, warn}; +#[cfg(feature = "otel")] +use tracing::warn_span; #[derive(Debug)] pub enum MixProcessingResultData { @@ -261,21 +267,27 @@ fn wrap_processed_sphinx_packet( // sphinx all together? ProcessedPacketData::FinalHop { destination, + #[cfg(feature = "otel")] identifier, + #[cfg(not(feature = "otel"))] + identifier: _, payload, } => { // if we have a trace id in the destination, we log it for easier correlation later on - // TODO add feature for otel - { - let trace_bytes: [u8; 12] = identifier[0..12].try_into().unwrap(); - if !trace_bytes.iter().all(|b| *b == 0) { + #[cfg(feature = "otel")] + let span = match identifier[0..12].try_into().map(|b: [u8; 12]| b) { + Ok(trace_bytes) if !trace_bytes.iter().all(|b| *b == 0) => { let full_trace_id_bytes = decompress_trace_id(&trace_bytes); let full_trace_id = opentelemetry::trace::TraceId::from_bytes(full_trace_id_bytes); let context_propagator = ManualContextPropagator::new_from_tid("final_hop", full_trace_id); - let span = warn_span!(parent: &context_propagator.root_span, "final_hop_processing", trace_id=%full_trace_id); - let _enter = span.enter(); + warn_span!(parent: &context_propagator.root_span, "final_hop_processing", trace_id=%full_trace_id) } - } + _ => { + warn_span!("final_hop_processing") + } + }; + #[cfg(feature = "otel")] + let _entered_span = span.enter(); process_final_hop( destination, diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index 984b953773..c5cdc5fd88 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -168,7 +168,6 @@ pub trait FragmentPreparer { /// - compute sphinx_plaintext = SURB_ACK || g^x || v_b /// - compute sphinx_packet = Sphinx(recipient, sphinx_plaintext) #[allow(clippy::too_many_arguments)] - #[instrument(skip_all)] fn prepare_chunk_for_sending( &mut self, fragment: Fragment, @@ -264,8 +263,8 @@ pub trait FragmentPreparer { )?, }; - /// - compute k = KDF(remote encryption key ^ x) this is equivalent to KDF( dh(remote, x) ) - /// from the previously constructed route extract the first hop + // - compute k = KDF(remote encryption key ^ x) this is equivalent to KDF( dh(remote, x) ) + // from the previously constructed route extract the first hop let first_hop_address = NymNodeRoutingAddress::try_from(route.first().unwrap().address).unwrap(); diff --git a/common/nyxd-scraper/Cargo.toml b/common/nyxd-scraper/Cargo.toml index 025e906d56..fb7781e230 100644 --- a/common/nyxd-scraper/Cargo.toml +++ b/common/nyxd-scraper/Cargo.toml @@ -32,8 +32,6 @@ tracing.workspace = true url.workspace = true -# TEMP -#nym-bin-common = { path = "../bin-common", features = ["basic_tracing"]} [build-dependencies] diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 886765c413..8d475bcbba 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -83,12 +83,22 @@ nym-service-provider-requests-common = { path = "../common/service-provider-requ defguard_wireguard_rs = { workspace = true } -opentelemetry.workspace = true -opentelemetry_sdk.workspace = true -tracing-opentelemetry.workspace = true +opentelemetry = { workspace = true, optional = true } +opentelemetry_sdk = { workspace = true, optional = true } +tracing-opentelemetry = { workspace = true, optional = true } [dev-dependencies] nym-gateway-storage = { path = "../common/gateway-storage", features = ["mock"] } nym-wireguard = { path = "../common/wireguard", features = ["mock"] } mock_instant = "0.6.0" time = { workspace = true } + +[features] +default = [] +otel = [ + "nym-bin-common/otel", + "nym-gateway-requests/otel", + "opentelemetry", + "opentelemetry_sdk", + "tracing-opentelemetry", +] diff --git a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs index 27654fcd80..ee37ccdfb1 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs @@ -14,6 +14,7 @@ use futures::{ future::{FusedFuture, OptionFuture}, FutureExt, StreamExt, }; +#[cfg(feature = "otel")] use nym_bin_common::opentelemetry::context::ManualContextPropagator; use nym_credential_verification::CredentialVerifier; use nym_credential_verification::{ @@ -32,7 +33,9 @@ use nym_sphinx::forwarding::packet::MixPacket; use nym_statistics_common::{gateways::GatewaySessionEvent, types::SessionType}; use nym_validator_client::coconut::EcashApiError; use rand::{random, CryptoRng, Rng}; -use std::{collections::HashMap, process, time::Duration}; +#[cfg(feature = "otel")] +use std::collections::HashMap; +use std::{process, time::Duration}; use thiserror::Error; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_tungstenite::tungstenite::{protocol::Message, Error as WsError}; @@ -148,6 +151,7 @@ pub(crate) struct AuthenticatedHandler { // senders that are used to return the result of the ping to the handler requesting the ping. is_active_request_receiver: IsActiveRequestReceiver, is_active_ping_pending_reply: Option<(u64, IsActiveResultSender)>, + #[cfg(feature = "otel")] otel_propagator: Option, } @@ -191,15 +195,19 @@ impl AuthenticatedHandler { client_address: client.address.as_base58_string(), })?; - let context = match client.otel_context { - Some(ref ctx) => ctx.clone(), - None => HashMap::new(), - }; + #[cfg(feature = "otel")] + let manual_ctx_propagator = { + let context = match client.otel_context { + Some(ref ctx) => ctx.clone(), + None => HashMap::new(), + }; - let manual_ctx_propagator = if !context.is_empty() { - Some(ManualContextPropagator::new("upgrading_fresh_to_authenticated", context)) - } else { - None + let manual_ctx_propagator = if !context.is_empty() { + Some(ManualContextPropagator::new("upgrading_fresh_to_authenticated", context)) + } else { + None + }; + manual_ctx_propagator }; let handler = AuthenticatedHandler { @@ -215,6 +223,7 @@ impl AuthenticatedHandler { mix_receiver, is_active_request_receiver, is_active_ping_pending_reply: None, + #[cfg(feature = "otel")] otel_propagator: manual_ctx_propagator, }; handler.send_metrics(GatewaySessionEvent::new_session_start( @@ -243,11 +252,14 @@ impl AuthenticatedHandler { /// * `mix_packet`: packet received from the client that should get forwarded into the network. #[instrument(skip_all)] fn forward_packet(&self, mix_packet: MixPacket) { - let span = match &self.otel_propagator { - Some(propagator) => info_span!(parent: &propagator.root_span, "forwarding_mix_packet"), - None => info_span!("forwarding_mix_packet_no_otel"), - }; - let _enter = span.enter(); + #[cfg(feature = "otel")] + { + let span = match &self.otel_propagator { + Some(propagator) => info_span!(parent: &propagator.root_span, "forwarding_mix_packet"), + None => info_span!("forwarding_mix_packet_no_otel"), + }; + let _enter = span.enter(); + } if let Err(err) = self .inner @@ -308,10 +320,16 @@ impl AuthenticatedHandler { &mut self, mix_packet: MixPacket, ) -> Result { - let span = match &self.otel_propagator { - Some(propagator) => info_span!(parent: &propagator.root_span, "handling_forward_sphinx"), - None => info_span!("handling_forward_sphinx_no_otel"), + trace!("forwarding sphinx packet"); + #[cfg(feature = "otel")] + let span = { + let span = match &self.otel_propagator { + Some(propagator) => info_span!(parent: &propagator.root_span, "handling_forward_sphinx"), + None => info_span!("handling_forward_sphinx_no_otel"), + }; + span }; + #[cfg(feature = "otel")] let _enter = span.enter(); let required_bandwidth = mix_packet.packet().len() as i64; @@ -335,10 +353,15 @@ impl AuthenticatedHandler { #[instrument(skip_all)] async fn handle_binary(&mut self, bin_msg: Vec) -> Message { trace!("binary request"); - let span = match &self.otel_propagator { - Some(propagator) => info_span!(parent: &propagator.root_span, "handling_binary_request"), - None => info_span!("handling_binary_request_no_otel"), + #[cfg(feature = "otel")] + let span = { + let span = match &self.otel_propagator { + Some(propagator) => info_span!(parent: &propagator.root_span, "handling_binary_request"), + None => info_span!("handling_binary_request_no_otel"), + }; + span }; + #[cfg(feature = "otel")] let _enter = span.enter(); // this function decrypts the request and checks the MAC @@ -653,11 +676,17 @@ impl AuthenticatedHandler { self.handle_ping_timeout().await; }, socket_msg = self.inner.read_websocket_message() => { - let span = match &self.otel_propagator { - Some(propagator) => info_span!(parent: &propagator.root_span, "client_message_received"), - None => info_span!("client_message_received_no_otel"), + #[cfg(feature = "otel")] + let span = { + let span = match &self.otel_propagator { + Some(propagator) => info_span!(parent: &propagator.root_span, "client_message_received"), + None => info_span!("client_message_received_no_otel"), + }; + span }; + #[cfg(feature = "otel")] let _enter = span.enter(); + let socket_msg = match socket_msg { None => break, Some(Ok(socket_msg)) => socket_msg, @@ -681,11 +710,17 @@ impl AuthenticatedHandler { } }, mix_messages = self.mix_receiver.next() => { - let span = match &self.otel_propagator { - Some(propagator) => info_span!(parent: &propagator.root_span, "mix_message_received"), - None => info_span!("mix_message_received_no_otel"), + #[cfg(feature = "otel")] + let span = { + let span = match &self.otel_propagator { + Some(propagator) => info_span!(parent: &propagator.root_span, "mix_message_received"), + None => info_span!("mix_message_received_no_otel"), + }; + span }; + #[cfg(feature = "otel")] let _enter = span.enter(); + let mix_messages = match mix_messages { None => { debug!("mix receiver was closed! Assuming the connection is dead."); diff --git a/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs b/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs index 14bd5da735..272c91e930 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs @@ -13,6 +13,7 @@ use futures::{ channel::{mpsc, oneshot}, SinkExt, StreamExt, }; +#[cfg(feature = "otel")] use nym_bin_common::opentelemetry::context::ManualContextPropagator; use nym_credentials_interface::AvailableBandwidth; use nym_crypto::aes::cipher::crypto_common::rand_core::RngCore; @@ -35,6 +36,7 @@ use nym_node_metrics::events::MetricsEvent; use nym_sphinx::DestinationAddressBytes; use nym_task::ShutdownToken; use rand::CryptoRng; +#[cfg(feature = "otel")] use std::collections::HashMap; use std::net::SocketAddr; use std::time::Duration; @@ -43,7 +45,9 @@ use time::OffsetDateTime; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::timeout; use tokio_tungstenite::tungstenite::{protocol::Message, Error as WsError}; -use tracing::{debug, error, info, info_span, instrument, warn}; +#[cfg(feature = "otel")] +use tracing::info_span; +use tracing::{debug, error, info, instrument, warn}; @@ -639,6 +643,7 @@ impl FreshHandler { address, shared_keys.key, session_request_start, + #[cfg(feature = "otel")] None, )), ServerResponse::Authenticate { @@ -655,6 +660,7 @@ impl FreshHandler { async fn handle_authenticate_v2( &mut self, request: Box, + #[cfg(feature = "otel")] otel_context: Option>, ) -> Result where @@ -730,6 +736,7 @@ impl FreshHandler { address, shared_key.key, session_request_start, + #[cfg(feature = "otel")] otel_context, )), ServerResponse::Authenticate { @@ -829,6 +836,7 @@ impl FreshHandler { remote_address, shared_keys, OffsetDateTime::now_utc(), + #[cfg(feature = "otel")] None ); @@ -869,7 +877,12 @@ impl FreshHandler { S: AsyncRead + AsyncWrite + Unpin + Send, R: CryptoRng + RngCore + Send, { + #[cfg(not(feature = "otel"))] + info!("[DEBUG] received initial client request no otel"); + #[cfg(feature = "otel")] + info!("[DEBUG] received initial client request with otel"); // extract and set up opentelemetry context if provided + #[cfg(feature = "otel")] let (context_propagator, otel_ctx) = if let ClientControlRequest::AuthenticateV2(ref auth_req) = request { if let Some(otel_context) = &auth_req.otel_context { warn!("OpenTelemetry context provided in the request: {otel_context:?}"); @@ -882,7 +895,7 @@ impl FreshHandler { warn!("No OpenTelemetry context provided in the request"); (None, None) }; - + #[cfg(feature = "otel")] let child_span = match context_propagator { Some(ref propagator) => { let span = info_span!(parent: &propagator.root_span, "=== Handling initial client request with otel context ==="); @@ -890,7 +903,7 @@ impl FreshHandler { } None => info_span!("=== Handling initial client request without otel context ==="), }; - + #[cfg(feature = "otel")] let _enter = child_span.enter(); let auth_result = match request { @@ -904,7 +917,10 @@ impl FreshHandler { self.handle_legacy_authenticate(protocol_version, address, enc_address, iv) .await } + #[cfg(feature = "otel")] ClientControlRequest::AuthenticateV2(req) => self.handle_authenticate_v2(req, otel_ctx).await, + #[cfg(not(feature = "otel"))] + ClientControlRequest::AuthenticateV2(req) => self.handle_authenticate_v2(req).await, ClientControlRequest::RegisterHandshakeInitRequest { protocol_version, data, diff --git a/gateway/src/node/client_handling/websocket/connection_handler/mod.rs b/gateway/src/node/client_handling/websocket/connection_handler/mod.rs index 232b2f4c74..01aee5b2c2 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/mod.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/mod.rs @@ -7,6 +7,7 @@ use nym_gateway_requests::shared_key::SharedGatewayKey; use nym_gateway_requests::ServerResponse; use nym_sphinx::DestinationAddressBytes; use rand::{CryptoRng, Rng}; +#[cfg(feature = "otel")] use std::collections::HashMap; use std::time::Duration; use time::OffsetDateTime; @@ -49,6 +50,7 @@ pub(crate) struct ClientDetails { // note, this does **NOT ALWAYS** indicate timestamp of when client connected // it is (for v2 auth) timestamp the client **signed** when it created the request pub(crate) session_request_timestamp: OffsetDateTime, + #[cfg(feature = "otel")] pub(crate) otel_context: Option>, } @@ -58,6 +60,7 @@ impl ClientDetails { address: DestinationAddressBytes, shared_keys: SharedGatewayKey, session_request_timestamp: OffsetDateTime, + #[cfg(feature = "otel")] otel_context: Option>, ) -> Self { ClientDetails { @@ -65,6 +68,7 @@ impl ClientDetails { id, shared_keys, session_request_timestamp, + #[cfg(feature = "otel")] otel_context, } } diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index 95d74bdb42..cfdeeb8302 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -94,7 +94,7 @@ nym-topology = { path = "../common/topology" } nym-api-requests = { path = "nym-api-requests" } nym-validator-client = { path = "../common/client-libs/validator-client" } nym-http-api-client = { path = "../common/http-api-client" } -nym-bin-common = { path = "../common/bin-common", features = ["output_format", "openapi", "basic_tracing"] } +nym-bin-common = { path = "../common/bin-common", features = ["output_format", "openapi"] } nym-node-tester-utils = { path = "../common/node-tester-utils" } nym-node-requests = { path = "../nym-node/nym-node-requests" } nym-types = { path = "../common/types" } diff --git a/nym-api/src/main.rs b/nym-api/src/main.rs index 96c7cb22d7..c96ae58bd9 100644 --- a/nym-api/src/main.rs +++ b/nym-api/src/main.rs @@ -31,7 +31,7 @@ async fn main() -> Result<(), anyhow::Error> { // instrument tokio console subscriber needs RUSTFLAGS="--cfg tokio_unstable" at build time console_subscriber::init(); } else { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); }} info!("Starting nym api..."); diff --git a/nym-credential-proxy/nym-credential-proxy/Cargo.toml b/nym-credential-proxy/nym-credential-proxy/Cargo.toml index d5b8252b96..e0974225be 100644 --- a/nym-credential-proxy/nym-credential-proxy/Cargo.toml +++ b/nym-credential-proxy/nym-credential-proxy/Cargo.toml @@ -45,9 +45,7 @@ utoipa = { workspace = true, features = ["axum_extras", "time"] } utoipa-swagger-ui = { workspace = true, features = ["axum"] } zeroize.workspace = true -nym-bin-common = { path = "../../common/bin-common", features = [ - "basic_tracing", -] } +nym-bin-common = { path = "../../common/bin-common" } nym-compact-ecash = { path = "../../common/nym_offline_compact_ecash" } nym-config = { path = "../../common/config" } nym-crypto = { path = "../../common/crypto", features = [ diff --git a/nym-credential-proxy/nym-credential-proxy/src/main.rs b/nym-credential-proxy/nym-credential-proxy/src/main.rs index 8b85fef400..638eea0b9a 100644 --- a/nym-credential-proxy/nym-credential-proxy/src/main.rs +++ b/nym-credential-proxy/nym-credential-proxy/src/main.rs @@ -6,7 +6,7 @@ cfg_if::cfg_if! { use crate::cli::Cli; use clap::Parser; use nym_bin_common::bin_info_owned; - use nym_bin_common::logging::setup_tracing_logger; + use nym_bin_common::logging::setup_no_otel_logger; use nym_network_defaults::setup_env; use tracing::{info, trace}; @@ -29,7 +29,7 @@ async fn main() -> anyhow::Result<()> { trace!("args: {cli:#?}"); setup_env(cli.config_env_file.as_ref()); - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); let bin_info = bin_info_owned!(); info!("using the following version: {bin_info}"); diff --git a/nym-network-monitor/Cargo.toml b/nym-network-monitor/Cargo.toml index a84a5f3c02..7463bb2926 100644 --- a/nym-network-monitor/Cargo.toml +++ b/nym-network-monitor/Cargo.toml @@ -30,7 +30,7 @@ utoipa-swagger-ui = { workspace = true, features = ["axum"] } tokio-postgres = { workspace = true } # internal -nym-bin-common = { path = "../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../common/bin-common" } nym-client-core = { path = "../common/client-core" } nym-crypto = { path = "../common/crypto" } nym-network-defaults = { path = "../common/network-defaults" } diff --git a/nym-network-monitor/src/main.rs b/nym-network-monitor/src/main.rs index 4dc9980f00..11628b6520 100644 --- a/nym-network-monitor/src/main.rs +++ b/nym-network-monitor/src/main.rs @@ -187,7 +187,7 @@ async fn nym_topology_from_env() -> anyhow::Result { #[tokio::main] async fn main() -> Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); let args = Args::parse(); diff --git a/nym-node/Cargo.toml b/nym-node/Cargo.toml index 4db2821c67..3707d91590 100644 --- a/nym-node/Cargo.toml +++ b/nym-node/Cargo.toml @@ -31,7 +31,7 @@ humantime-serde = { workspace = true } human-repr = { workspace = true } ipnetwork = { workspace = true } indicatif = { workspace = true } -opentelemetry = { workspace = true } # make it optional later +opentelemetry = { workspace = true, optional = true } # make it optional later rand = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json.workspace = true @@ -51,7 +51,6 @@ cupid = { workspace = true } sysinfo = { workspace = true } nym-bin-common = { path = "../common/bin-common", features = [ - "basic_tracing", "output_format", ] } nym-client-core-config-types = { path = "../common/client-core/config-types", features = [ @@ -131,10 +130,15 @@ criterion = { workspace = true, features = ["async_tokio"] } rand_chacha = { workspace = true } [features] -default = ["otel"] # 🚨🚨🚨 TODO: remove otel as a default feature 🚨🚨🚨 +default = [] tokio-console = ["console-subscriber"] otel = [ - + "nym-bin-common/otel", + "nym-gateway/otel", + "nym-http-api-common/otel", + "nym-sphinx-framing/otel", + "nym-sphinx-addressing/otel", + "opentelemetry", ] diff --git a/nym-node/src/cli/mod.rs b/nym-node/src/cli/mod.rs index 242c11686a..2bc5b32e21 100644 --- a/nym-node/src/cli/mod.rs +++ b/nym-node/src/cli/mod.rs @@ -10,11 +10,13 @@ use crate::env::vars::{NYMNODE_CONFIG_ENV_FILE_ARG, NYMNODE_NO_BANNER_ARG}; use clap::{Args, Parser, Subcommand}; use nym_bin_common::{ bin_info, - opentelemetry::{ - setup_no_otel_logger, - setup_tracing_logger, - error::TracingError}, + logging::setup_no_otel_logger, }; +#[cfg(feature = "otel")] +use nym_bin_common::logging::error::TracingError; +#[cfg(feature = "otel")] +use nym_bin_common::opentelemetry::setup_tracing_logger; +#[cfg(feature = "otel")] use opentelemetry::{Context, global, trace::{TraceContextExt, Tracer}}; use std::future::Future; use std::sync::OnceLock; @@ -89,33 +91,47 @@ impl Cli { }, // SigNoz/OTEL run in async context Commands::BondingInformation(args) => Self::execute_async(async move { - let _guard = setup_tracing_logger("nym-node".to_string()) + #[cfg(feature = "otel")] + setup_tracing_logger("nym-node".to_string()) .map_err(TracingError::from)?; - + #[cfg(not(feature = "otel"))] + setup_no_otel_logger().expect("failed to initialize logging"); bonding_information::execute(args).await?; Ok::<(), anyhow::Error>(()) })??, Commands::NodeDetails(args) => Self::execute_async(async move { - let _guard = setup_tracing_logger("nym-node".to_string()) + #[cfg(feature = "otel")] + setup_tracing_logger("nym-node".to_string()) .map_err(TracingError::from)?; + #[cfg(not(feature = "otel"))] + setup_no_otel_logger().expect("failed to initialize logging"); node_details::execute(args).await?; Ok::<(), anyhow::Error>(()) })??, Commands::Run(args) => Self::execute_async(async move { - let _guard = setup_tracing_logger("nym-node".to_string()) + #[cfg(feature = "otel")] + setup_tracing_logger("nym-node".to_string()) .map_err(TracingError::from)?; + #[cfg(not(feature = "otel"))] + setup_no_otel_logger().expect("failed to initialize logging"); run::execute(*args).await?; Ok::<(), anyhow::Error>(()) })??, Commands::Sign(args) => Self::execute_async(async move { - let _guard = setup_tracing_logger("nym-node".to_string()) + #[cfg(feature = "otel")] + setup_tracing_logger("nym-node".to_string()) .map_err(TracingError::from)?; + #[cfg(not(feature = "otel"))] + setup_no_otel_logger().expect("failed to initialize logging"); sign::execute(args).await?; Ok::<(), anyhow::Error>(()) })??, Commands::UnsafeResetSphinxKeys(args) => Self::execute_async(async move { - let _guard = setup_tracing_logger("nym-node".to_string()) + #[cfg(feature = "otel")] + setup_tracing_logger("nym-node".to_string()) .map_err(TracingError::from)?; + #[cfg(not(feature = "otel"))] + setup_no_otel_logger().expect("failed to initialize logging"); reset_sphinx_keys::execute(args).await?; Ok::<(), anyhow::Error>(()) })??, diff --git a/nym-signers-monitor/Cargo.toml b/nym-signers-monitor/Cargo.toml index d043aa2871..b0c57e0737 100644 --- a/nym-signers-monitor/Cargo.toml +++ b/nym-signers-monitor/Cargo.toml @@ -20,7 +20,7 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tracing = { workspace = true } url = { workspace = true } -nym-bin-common = { path = "../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../common/bin-common", features = ["output_format"] } nym-ecash-signer-check = { path = "../common/ecash-signer-check" } nym-network-defaults = { path = "../common/network-defaults" } nym-task = { path = "../common/task" } diff --git a/nym-signers-monitor/src/main.rs b/nym-signers-monitor/src/main.rs index b2955277e0..855bea0e2d 100644 --- a/nym-signers-monitor/src/main.rs +++ b/nym-signers-monitor/src/main.rs @@ -4,7 +4,7 @@ use crate::cli::Cli; use clap::Parser; use nym_bin_common::bin_info_owned; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use tracing::{info, trace}; mod cli; @@ -13,7 +13,7 @@ pub(crate) mod test_result; #[tokio::main] async fn main() -> anyhow::Result<()> { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); let cli = Cli::parse(); trace!("args: {cli:#?}"); diff --git a/nym-validator-rewarder/Cargo.toml b/nym-validator-rewarder/Cargo.toml index be1ae056dc..e99f64b69b 100644 --- a/nym-validator-rewarder/Cargo.toml +++ b/nym-validator-rewarder/Cargo.toml @@ -32,8 +32,8 @@ humantime = { workspace = true } humantime-serde.workspace = true # internal -nym-bin-common = { path = "../common/bin-common", features = ["output_format", "basic_tracing"] } -nym-config = { path = "../common/config" } +nym-bin-common = { path = "../common/bin-common", features = ["output_format"] } +nym-config = { path = "../common/config" } nym-ecash-time = { path = "../common/ecash-time" } nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } nym-compact-ecash = { path = "../common/nym_offline_compact_ecash" } diff --git a/nym-validator-rewarder/src/main.rs b/nym-validator-rewarder/src/main.rs index e8945316a5..709e46158a 100644 --- a/nym-validator-rewarder/src/main.rs +++ b/nym-validator-rewarder/src/main.rs @@ -8,7 +8,7 @@ use crate::cli::Cli; use clap::{crate_name, crate_version, Parser}; -use nym_bin_common::logging::{maybe_print_banner, setup_tracing_logger}; +use nym_bin_common::logging::{maybe_print_banner, setup_no_otel_logger}; use nym_network_defaults::setup_env; pub mod cli; @@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> { let args = Cli::parse(); setup_env(args.config_env_file.as_ref()); - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); if !args.no_banner { maybe_print_banner(crate_name!(), crate_version!()); diff --git a/nym-wallet/nym-wallet-recovery-cli/Cargo.toml b/nym-wallet/nym-wallet-recovery-cli/Cargo.toml index 5d78d02d41..72add6df86 100644 --- a/nym-wallet/nym-wallet-recovery-cli/Cargo.toml +++ b/nym-wallet/nym-wallet-recovery-cli/Cargo.toml @@ -13,5 +13,5 @@ clap = { version = "4.0", features = ["derive"] } log = "0.4" serde_json = "1.0.0" -nym-bin-common = { path = "../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common" } nym-store-cipher = { path = "../../common/store-cipher" } diff --git a/nym-wallet/nym-wallet-recovery-cli/src/main.rs b/nym-wallet/nym-wallet-recovery-cli/src/main.rs index 0162eaa826..06d3c5bf48 100644 --- a/nym-wallet/nym-wallet-recovery-cli/src/main.rs +++ b/nym-wallet/nym-wallet-recovery-cli/src/main.rs @@ -8,7 +8,7 @@ use anyhow::{anyhow, Result}; use clap::Parser; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use nym_store_cipher::{ Aes256Gcm, Algorithm, EncryptedData, KdfInfo, Params, StoreCipher, Version, ARGON2_SALT_SIZE, CURRENT_VERSION, @@ -52,7 +52,7 @@ enum ParseMode { } fn main() -> Result<()> { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); let args = Args::parse(); let file = File::open(args.file)?; let parse = if args.raw { diff --git a/sdk/ffi/cpp/Cargo.toml b/sdk/ffi/cpp/Cargo.toml index 8ac5f608db..7b49a98540 100644 --- a/sdk/ffi/cpp/Cargo.toml +++ b/sdk/ffi/cpp/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib"] tokio = { workspace = true, features = ["full"] } # Nym clients, addressing, packet format, common tools (logging), ffi shared nym-sdk = { path = "../../rust/nym-sdk/" } -nym-bin-common = { path = "../../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../../common/bin-common" } nym-sphinx-anonymous-replies = { path = "../../../common/nymsphinx/anonymous-replies" } nym-ffi-shared = { path = "../shared" } lazy_static = { workspace = true } diff --git a/sdk/ffi/cpp/src/lib.rs b/sdk/ffi/cpp/src/lib.rs index 110f0e2fbe..6f9b9eb4a1 100644 --- a/sdk/ffi/cpp/src/lib.rs +++ b/sdk/ffi/cpp/src/lib.rs @@ -12,7 +12,7 @@ use crate::types::types::{CMessageCallback, CStringCallback, ReceivedMessage, St #[no_mangle] pub extern "C" fn init_logging() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); } #[no_mangle] diff --git a/sdk/ffi/go/Cargo.toml b/sdk/ffi/go/Cargo.toml index 3366f424a5..73c34b60a0 100644 --- a/sdk/ffi/go/Cargo.toml +++ b/sdk/ffi/go/Cargo.toml @@ -14,7 +14,7 @@ uniffi = { workspace = true, features = ["cli"] } # Nym clients, addressing, packet format, common tools (logging), ffi shared nym-sdk = { path = "../../rust/nym-sdk/" } nym-crypto = { path = "../../../common/crypto" } -nym-bin-common = { path = "../../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../../common/bin-common" } nym-sphinx-anonymous-replies = { path = "../../../common/nymsphinx/anonymous-replies" } nym-ffi-shared = { path = "../shared" } # Async runtime diff --git a/sdk/ffi/go/src/lib.rs b/sdk/ffi/go/src/lib.rs index 49bf098c44..c3632facc1 100644 --- a/sdk/ffi/go/src/lib.rs +++ b/sdk/ffi/go/src/lib.rs @@ -36,7 +36,7 @@ enum GoWrapError { #[no_mangle] fn init_logging() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); } #[no_mangle] diff --git a/sdk/rust/nym-sdk/Cargo.toml b/sdk/rust/nym-sdk/Cargo.toml index 545ee92ee1..1b448ca59d 100644 --- a/sdk/rust/nym-sdk/Cargo.toml +++ b/sdk/rust/nym-sdk/Cargo.toml @@ -43,9 +43,7 @@ nym-socks5-requests = { path = "../../../common/socks5/requests" } nym-ordered-buffer = { path = "../../../common/socks5/ordered-buffer" } nym-service-providers-common = { path = "../../../service-providers/common" } nym-sphinx-addressing = { path = "../../../common/nymsphinx/addressing" } -nym-bin-common = { path = "../../../common/bin-common", features = [ - "basic_tracing", -] } +nym-bin-common = { path = "../../../common/bin-common" } bytecodec = { workspace = true } httpcodec = { workspace = true } bytes = { workspace = true } @@ -75,15 +73,15 @@ serde = { workspace = true, features = ["derive"] } # tracing-subscriber = { workspace = true, features = ["env-filter"] } dirs.workspace = true -opentelemetry = { workspace = true } -opentelemetry_sdk = { workspace = true } +opentelemetry = { workspace = true, optional = true} +opentelemetry_sdk = { workspace = true, optional = true } tracing = { workspace = true, features = ["std"] } tracing-subscriber = { workspace = true, features = ["registry", "std"] } tracing-core = { workspace = true } -tracing-opentelemetry = { workspace = true } -opentelemetry-otlp.workspace = true -opentelemetry-semantic-conventions.workspace = true +tracing-opentelemetry = { workspace = true, optional = true } +opentelemetry-otlp = { workspace = true, optional = true } +opentelemetry-semantic-conventions = { workspace = true, optional = true } [dev-dependencies] anyhow = { workspace = true } @@ -92,7 +90,7 @@ reqwest = { workspace = true, features = ["json", "socks"] } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } time = { workspace = true } -nym-bin-common = { path = "../../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../../common/bin-common" } # extra dependencies for libp2p examples #libp2p = { git = "https://github.com/ChainSafe/rust-libp2p.git", rev = "e3440d25681df380c9f0f8cfdcfd5ecc0a4f2fb6", features = [ "identify", "macros", "ping", "tokio", "tcp", "dns", "websocket", "noise", "mplex", "yamux", "gossipsub" ]} @@ -103,3 +101,12 @@ hex = { workspace = true } [features] libp2p-vanilla = [] +otel = [ + "nym-bin-common/otel", + "nym-gateway-requests/otel", + "opentelemetry", + "opentelemetry_sdk", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "tracing-opentelemetry", +] diff --git a/sdk/rust/nym-sdk/examples/bandwidth.rs b/sdk/rust/nym-sdk/examples/bandwidth.rs index 510c225946..4d193abd13 100644 --- a/sdk/rust/nym-sdk/examples/bandwidth.rs +++ b/sdk/rust/nym-sdk/examples/bandwidth.rs @@ -6,7 +6,7 @@ use nym_sdk::mixnet::MixnetMessageSender; #[tokio::main] async fn main() -> anyhow::Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // right now, only sandbox has coconut setup // this should be run from the `sdk/rust/nym-sdk` directory setup_env(Some("../../../envs/sandbox.env")); diff --git a/sdk/rust/nym-sdk/examples/builder.rs b/sdk/rust/nym-sdk/examples/builder.rs index f0da9afc11..04bab95154 100644 --- a/sdk/rust/nym-sdk/examples/builder.rs +++ b/sdk/rust/nym-sdk/examples/builder.rs @@ -3,7 +3,7 @@ use nym_sdk::mixnet::MixnetMessageSender; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Create client builder, including ephemeral keys. The builder can be usable in the context // where you don't want to connect just yet. diff --git a/sdk/rust/nym-sdk/examples/builder_with_storage.rs b/sdk/rust/nym-sdk/examples/builder_with_storage.rs index 51fbc6b598..e550de741b 100644 --- a/sdk/rust/nym-sdk/examples/builder_with_storage.rs +++ b/sdk/rust/nym-sdk/examples/builder_with_storage.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Specify some config options let config_dir = PathBuf::from("/tmp/mixnet-client"); diff --git a/sdk/rust/nym-sdk/examples/change_gateway.rs b/sdk/rust/nym-sdk/examples/change_gateway.rs index d4ad49536c..82547145d2 100644 --- a/sdk/rust/nym-sdk/examples/change_gateway.rs +++ b/sdk/rust/nym-sdk/examples/change_gateway.rs @@ -3,7 +3,7 @@ #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); todo!() } diff --git a/sdk/rust/nym-sdk/examples/client_pool.rs b/sdk/rust/nym-sdk/examples/client_pool.rs index 432564218c..d1fa9598a4 100644 --- a/sdk/rust/nym-sdk/examples/client_pool.rs +++ b/sdk/rust/nym-sdk/examples/client_pool.rs @@ -12,7 +12,7 @@ use tokio::signal::ctrl_c; // Run with: cargo run --example client_pool -- ../../../envs/.env #[tokio::main] async fn main() -> Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to setup logging"); setup_env(std::env::args().nth(1)); let conn_pool = ClientPool::new(2); // Start the Client Pool with 2 Clients always being kept in reserve diff --git a/sdk/rust/nym-sdk/examples/custom_topology_provider.rs b/sdk/rust/nym-sdk/examples/custom_topology_provider.rs index 00758a2482..d5c751f037 100644 --- a/sdk/rust/nym-sdk/examples/custom_topology_provider.rs +++ b/sdk/rust/nym-sdk/examples/custom_topology_provider.rs @@ -3,83 +3,18 @@ use futures::StreamExt; use nym_sdk::mixnet::MixnetMessageSender; -use nym_sdk::{mixnet, DebugConfig}; -use nym_topology::provider_trait::{async_trait, ToTopologyMetadata, TopologyProvider}; +use nym_sdk::{mixnet}; use nym_topology::{ - CachedEpochRewardedSet, EntryDetails, EpochRewardedSet, HardcodedTopologyProvider, NymTopology, + CachedEpochRewardedSet, EntryDetails, HardcodedTopologyProvider, NymTopology, NymTopologyMetadata, RoutingNode, SupportedRoles, }; -use nym_validator_client::nym_api::NymApiClientExt; use std::time::Duration; use time::OffsetDateTime; use tokio::time::sleep; -use url::Url; -// -// struct MyTopologyProvider { -// validator_client: nym_http_api_client::Client, -// } -// -// impl MyTopologyProvider { -// fn new(nym_api_url: Url) -> MyTopologyProvider { -// let validator_client = nym_http_api_client::Client::builder(nym_api_url) -// .expect("Failed to create API client builder") -// .build() -// .expect("Failed to build API client"); -// -// MyTopologyProvider { validator_client } -// } -// -// async fn get_topology(&self) -> NymTopology { -// let rewarded_set = self -// .validator_client -// .get_current_rewarded_set() -// .await -// .unwrap(); -// -// let mixnodes_response = self -// .validator_client -// .get_all_basic_active_mixing_assigned_nodes_with_metadata() -// .await -// .unwrap(); -// -// let metadata = mixnodes_response.metadata.to_topology_metadata(); -// -// let epoch_rewarded_set: EpochRewardedSet = rewarded_set.into(); -// let mut base_topology = NymTopology::new(metadata, epoch_rewarded_set, Vec::new()); -// -// // in our topology provider only use mixnodes that have node_id divisible by 3 -// // and has exactly 100 performance score -// // why? because this is just an example to showcase arbitrary uses and capabilities of this trait -// let filtered_mixnodes = mixnodes_response -// .nodes -// .into_iter() -// .filter(|mix| mix.node_id % 3 == 0 && mix.performance.is_hundred()) -// .collect::>(); -// -// let gateways = self -// .validator_client -// .get_all_basic_entry_assigned_nodes_with_metadata() -// .await -// .unwrap() -// .nodes; -// -// base_topology.add_skimmed_nodes(&filtered_mixnodes); -// base_topology.add_skimmed_nodes(&gateways); -// base_topology -// } -// } -// -// #[async_trait] -// impl TopologyProvider for MyTopologyProvider { -// // this will be manually refreshed on a timer specified inside mixnet client config -// async fn get_new_topology(&mut self) -> Option { -// Some(self.get_topology().await) -// } -// } #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to setup logging"); // let nym_api = "https://validator.nymtech.net/api/".parse().unwrap(); // let my_topology_provider = MyTopologyProvider::new(nym_api); diff --git a/sdk/rust/nym-sdk/examples/local_surb_example.rs b/sdk/rust/nym-sdk/examples/local_surb_example.rs index 0273c22786..0ccd31f2c0 100644 --- a/sdk/rust/nym-sdk/examples/local_surb_example.rs +++ b/sdk/rust/nym-sdk/examples/local_surb_example.rs @@ -2,7 +2,9 @@ use nym_sdk::mixnet::{ AnonymousSenderTag, MixnetClientBuilder, MixnetMessageSender, ReconstructedMessage, }; use nym_topology::{CachedEpochRewardedSet, EntryDetails, HardcodedTopologyProvider, NymTopology, NymTopologyMetadata, RoutingNode, SupportedRoles}; +#[cfg(feature = "otel")] use opentelemetry::trace::{TraceContextExt, Tracer}; +#[cfg(feature = "otel")] use opentelemetry::{global, Context}; use time::OffsetDateTime; use tracing::warn; @@ -11,15 +13,20 @@ use tracing::instrument; #[tokio::main] #[instrument(name = "sdk-example-surb-reply", skip_all)] async fn main() { - nym_bin_common::opentelemetry::setup_tracing_logger("local-sdk-example-surb-reply".to_string()).unwrap(); + #[cfg(feature = "otel")] + { + nym_bin_common::opentelemetry::setup_tracing_logger("local-sdk-example-surb-reply".to_string()).unwrap(); - let tracer = global::tracer("local-sdk-example-surb-reply"); - let span = tracer.start("client-root-span"); - let cx = Context::current_with_span(span); - let _guard = cx.clone().attach(); + let tracer = global::tracer("local-sdk-example-surb-reply"); + let span = tracer.start("client-root-span"); + let cx = Context::current_with_span(span); + let _guard = cx.clone().attach(); - let trace_id = cx.span().span_context().trace_id(); - warn!("Main TRACE_ID: {:?}", trace_id); + let trace_id = cx.span().span_context().trace_id(); + warn!("Main TRACE_ID: {:?}", trace_id); + } + #[cfg(not(feature = "otel"))] + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Create a mixnet client which connect to a local node let topology_metadata = NymTopologyMetadata::new(0, 0, OffsetDateTime::now_utc()); @@ -38,10 +45,10 @@ async fn main() { hostname: None, clients_wss_port: None, }), - identity_key: "Put Your Identity Key Here" + identity_key: "put here identity_key" .parse() .unwrap(), - sphinx_key: "Put Your Sphinx Key Here" + sphinx_key: "put here sphinx_key" .parse() .unwrap(), supported_roles: SupportedRoles { diff --git a/sdk/rust/nym-sdk/examples/manually_handle_storage.rs b/sdk/rust/nym-sdk/examples/manually_handle_storage.rs index 87ba92c2ec..34f6f4cdcc 100644 --- a/sdk/rust/nym-sdk/examples/manually_handle_storage.rs +++ b/sdk/rust/nym-sdk/examples/manually_handle_storage.rs @@ -8,7 +8,7 @@ use nym_topology::provider_trait::async_trait; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Just some plain data to pretend we have some external storage that the application // implementer is using. diff --git a/sdk/rust/nym-sdk/examples/manually_overwrite_topology.rs b/sdk/rust/nym-sdk/examples/manually_overwrite_topology.rs index 470fca4b83..5b58e19350 100644 --- a/sdk/rust/nym-sdk/examples/manually_overwrite_topology.rs +++ b/sdk/rust/nym-sdk/examples/manually_overwrite_topology.rs @@ -7,7 +7,7 @@ use nym_topology::{NymTopology, NymTopologyMetadata, RoutingNode, SupportedRoles #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Passing no config makes the client fire up an ephemeral session and figure shit out on its own let mut client = mixnet::MixnetClient::connect_new().await.unwrap(); diff --git a/sdk/rust/nym-sdk/examples/parallel_sending_and_receiving.rs b/sdk/rust/nym-sdk/examples/parallel_sending_and_receiving.rs index b42ad5ef04..8739962839 100644 --- a/sdk/rust/nym-sdk/examples/parallel_sending_and_receiving.rs +++ b/sdk/rust/nym-sdk/examples/parallel_sending_and_receiving.rs @@ -7,7 +7,7 @@ use nym_sdk::mixnet::MixnetMessageSender; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Passing no config makes the client fire up an ephemeral session and figure stuff out on its own let mut client = mixnet::MixnetClient::connect_new().await.unwrap(); diff --git a/sdk/rust/nym-sdk/examples/sandbox.rs b/sdk/rust/nym-sdk/examples/sandbox.rs index c3407a2124..d74bd23ba2 100644 --- a/sdk/rust/nym-sdk/examples/sandbox.rs +++ b/sdk/rust/nym-sdk/examples/sandbox.rs @@ -6,7 +6,7 @@ use nym_sdk::mixnet::MixnetMessageSender; // An example of creating a client relying on a testnet, in this case Sandbox. #[tokio::main] async fn main() -> anyhow::Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // relative root is `sdk/rust/nym-sdk/` for fallback file path let env_path = std::env::var("NYM_ENV_PATH").unwrap_or_else(|_| "../../../envs/sandbox.env".to_string()); diff --git a/sdk/rust/nym-sdk/examples/simple.rs b/sdk/rust/nym-sdk/examples/simple.rs index 55ecfb886d..a2ca0f7c54 100644 --- a/sdk/rust/nym-sdk/examples/simple.rs +++ b/sdk/rust/nym-sdk/examples/simple.rs @@ -3,7 +3,7 @@ use nym_sdk::mixnet::MixnetMessageSender; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Passing no config makes the client fire up an ephemeral session and figure shit out on its own // let mut client = mixnet::MixnetClient::connect_new().await.unwrap(); diff --git a/sdk/rust/nym-sdk/examples/socks5.rs b/sdk/rust/nym-sdk/examples/socks5.rs index a80c65b56d..f02dd115df 100644 --- a/sdk/rust/nym-sdk/examples/socks5.rs +++ b/sdk/rust/nym-sdk/examples/socks5.rs @@ -2,7 +2,7 @@ use nym_sdk::mixnet; #[tokio::main] async fn main() { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); println!("Connecting receiver"); let mut receiving_client = mixnet::MixnetClient::connect_new().await.unwrap(); diff --git a/sdk/rust/nym-sdk/examples/surb_reply.rs b/sdk/rust/nym-sdk/examples/surb_reply.rs index 8a07ba1490..2e4cc4bd5a 100644 --- a/sdk/rust/nym-sdk/examples/surb_reply.rs +++ b/sdk/rust/nym-sdk/examples/surb_reply.rs @@ -2,7 +2,9 @@ use nym_sdk::mixnet::{ AnonymousSenderTag, MixnetClientBuilder, MixnetMessageSender, ReconstructedMessage, }; use nym_sdk::DebugConfig; +#[cfg(feature = "otel")] use opentelemetry::trace::{TraceContextExt, Tracer}; +#[cfg(feature = "otel")] use opentelemetry::{global, Context}; use tracing::warn; use tracing::instrument; @@ -10,18 +12,26 @@ use tracing::instrument; #[tokio::main] #[instrument(name = "sdk-example-surb-reply", skip_all)] async fn main() { - let _guard = nym_bin_common::opentelemetry::setup_tracing_logger("sdk-example-surb-reply".to_string()).unwrap(); + // Setup OpenTelemetry tracing + #[cfg(feature = "otel")] + let _guard = { + nym_bin_common::opentelemetry::setup_tracing_logger("sdk-example-surb-reply".to_string()).unwrap(); - let tracer = global::tracer("sdk-example-surb-reply"); - let span = tracer.start("client-root-span"); - let cx = Context::current_with_span(span); - let _guard = cx.clone().attach(); + let tracer = global::tracer("sdk-example-surb-reply"); + let span = tracer.start("client-root-span"); + let cx = Context::current_with_span(span); + let _guard = cx.clone().attach(); - let trace_id = cx.span().span_context().trace_id(); - warn!("Main TRACE_ID: {:?}", trace_id); + let trace_id = cx.span().span_context().trace_id(); + warn!("Main TRACE_ID: {:?}", trace_id); - let context = Context::current(); - println!("Current OTEL context: {:?}", context); + let context = Context::current(); + println!("Current OTEL context: {:?}", context); + + _guard + }; + #[cfg(not(feature = "otel"))] + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); // Ignore performance requirements for the sake of the example let mut debug_config = DebugConfig::default(); diff --git a/sdk/rust/nym-sdk/src/mixnet/client.rs b/sdk/rust/nym-sdk/src/mixnet/client.rs index 0fd748294b..9cf959c12c 100644 --- a/sdk/rust/nym-sdk/src/mixnet/client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/client.rs @@ -73,6 +73,7 @@ pub struct MixnetClientBuilder { impl MixnetClientBuilder { /// Creates a client builder with ephemeral storage. #[must_use] + #[instrument(name = "MixnetClientBuilder::new_ephemeral", skip_all)] pub fn new_ephemeral() -> Self { MixnetClientBuilder { ..Default::default() @@ -81,6 +82,7 @@ impl MixnetClientBuilder { /// Create a client builder with default values. #[must_use] + #[instrument(name = "MixnetClientBuilder::new", skip_all)] pub fn new() -> Self { Self::new_ephemeral() } diff --git a/sdk/rust/nym-sdk/src/mixnet/native_client.rs b/sdk/rust/nym-sdk/src/mixnet/native_client.rs index 4cd7f65890..5fafae9a8c 100644 --- a/sdk/rust/nym-sdk/src/mixnet/native_client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/native_client.rs @@ -24,6 +24,7 @@ use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use tokio::sync::RwLockReadGuard; +use tracing::instrument; /// Client connected to the Nym mixnet. pub struct MixnetClient { @@ -64,6 +65,7 @@ pub struct MixnetClient { impl MixnetClient { #[allow(clippy::too_many_arguments)] + #[instrument(name = "MixnetClient::new", skip_all)] pub(crate) fn new( nym_address: Recipient, identity_keys: Arc, diff --git a/sdk/rust/nym-sdk/src/mixnet/traits.rs b/sdk/rust/nym-sdk/src/mixnet/traits.rs index f8374d963d..af40b37300 100644 --- a/sdk/rust/nym-sdk/src/mixnet/traits.rs +++ b/sdk/rust/nym-sdk/src/mixnet/traits.rs @@ -5,10 +5,14 @@ use crate::mixnet::{AnonymousSenderTag, IncludedSurbs, Recipient}; use crate::Result; use async_trait::async_trait; use nym_client_core::client::inbound_messages::InputMessage; +#[cfg(feature = "otel" +)] use nym_bin_common::opentelemetry::compact_id_generator::compress_trace_id; use nym_sphinx::params::PacketType; use nym_task::connections::TransmissionLane; +#[cfg(feature = "otel")] use opentelemetry::trace::TraceContextExt; +#[cfg(feature = "otel")] use opentelemetry::Context; use tracing::instrument; @@ -77,10 +81,14 @@ pub trait MixnetMessageSender { { // In case of surb opentelemetry tracing, we extract the context and trace_id // in the 12 bytes format - let context = Context::current(); - let trace_id = context.span().span_context().trace_id(); - tracing::warn!("Extracted trace_id from surb context: {:?}", trace_id); - let trace_id = compress_trace_id(&trace_id); + #[cfg(feature = "otel")] + let trace_id = { + let context = Context::current(); + let trace_id = context.span().span_context().trace_id(); + Some(compress_trace_id(&trace_id)) + }; + #[cfg(not(feature = "otel"))] + let trace_id = None; let lane = TransmissionLane::General; let input_msg = match surbs { @@ -90,14 +98,14 @@ pub trait MixnetMessageSender { surbs, lane, self.packet_type(), - Some(trace_id) + trace_id, ), IncludedSurbs::ExposeSelfAddress => InputMessage::new_regular( address, message.as_ref().to_vec(), lane, self.packet_type(), - Some(trace_id) + trace_id, ), }; self.send(input_msg).await diff --git a/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_client.rs b/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_client.rs index 3b6d24da1d..dc5aa6d60b 100644 --- a/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_client.rs +++ b/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_client.rs @@ -32,7 +32,7 @@ struct Args { #[tokio::main] async fn main() -> Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to setup logging"); let args = Args::parse(); let nym_addr: Recipient = diff --git a/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_server.rs b/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_server.rs index 6633ce87a5..f2858c563c 100644 --- a/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_server.rs +++ b/sdk/rust/nym-sdk/src/tcp_proxy/bin/proxy_server.rs @@ -23,7 +23,7 @@ struct Args { #[tokio::main] async fn main() -> Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to setup logging"); let args = Args::parse(); diff --git a/service-providers/ip-packet-router/Cargo.toml b/service-providers/ip-packet-router/Cargo.toml index c69d1caa20..14cedf7743 100644 --- a/service-providers/ip-packet-router/Cargo.toml +++ b/service-providers/ip-packet-router/Cargo.toml @@ -17,7 +17,7 @@ clap.workspace = true etherparse = { workspace = true } futures = { workspace = true } log = { workspace = true } -nym-bin-common = { path = "../../common/bin-common", features = ["clap", "basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common", features = ["clap"] } nym-client-core = { path = "../../common/client-core" } nym-config = { path = "../../common/config" } nym-crypto = { path = "../../common/crypto" } diff --git a/service-providers/ip-packet-router/src/main.rs b/service-providers/ip-packet-router/src/main.rs index f1987ed6ab..68da2f6cc9 100644 --- a/service-providers/ip-packet-router/src/main.rs +++ b/service-providers/ip-packet-router/src/main.rs @@ -10,7 +10,7 @@ async fn main() -> anyhow::Result<()> { use clap::Parser; let args = cli::Cli::parse(); - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); nym_network_defaults::setup_env(args.config_env_file.as_ref()); if !args.no_banner { diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index d13c60bc1f..69b598904a 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -43,7 +43,7 @@ zeroize = { workspace = true } # internal nym-async-file-watcher = { path = "../../common/async-file-watcher" } -nym-bin-common = { path = "../../common/bin-common", features = ["output_format", "clap", "basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common", features = ["output_format", "clap"] } nym-client-core = { path = "../../common/client-core", features = ["cli", "fs-gateways-storage", "fs-surb-storage"] } nym-client-websocket-requests = { path = "../../clients/native/websocket-requests" } nym-config = { path = "../../common/config" } diff --git a/service-providers/network-requester/src/main.rs b/service-providers/network-requester/src/main.rs index 686019b575..4f2169ae8e 100644 --- a/service-providers/network-requester/src/main.rs +++ b/service-providers/network-requester/src/main.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only use clap::{crate_name, crate_version, Parser}; -use nym_bin_common::logging::{maybe_print_banner, setup_tracing_logger}; +use nym_bin_common::logging::{maybe_print_banner, setup_no_otel_logger}; use nym_network_defaults::setup_env; mod cli; @@ -21,7 +21,7 @@ async fn main() -> anyhow::Result<()> { if !args.no_banner { maybe_print_banner(crate_name!(), crate_version!()); } - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); cli::execute(args).await?; diff --git a/tools/echo-server/Cargo.toml b/tools/echo-server/Cargo.toml index 390f746bcc..48f02f8670 100644 --- a/tools/echo-server/Cargo.toml +++ b/tools/echo-server/Cargo.toml @@ -31,7 +31,6 @@ bytes.workspace = true dirs.workspace = true clap.workspace = true nym-bin-common = { path = "../../common/bin-common", features = [ - "basic_tracing", "output_format", ] } nym-crypto = { path = "../../common/crypto", features = ["asymmetric"] } diff --git a/tools/echo-server/src/echo-server.rs b/tools/echo-server/src/echo-server.rs index 09f0b3725d..f081103043 100644 --- a/tools/echo-server/src/echo-server.rs +++ b/tools/echo-server/src/echo-server.rs @@ -28,7 +28,7 @@ struct Args { #[tokio::main] async fn main() -> Result<()> { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); let args = Args::parse(); let mut echo_server = NymEchoServer::new( args.gateway, diff --git a/tools/internal/contract-state-importer/importer-cli/Cargo.toml b/tools/internal/contract-state-importer/importer-cli/Cargo.toml index db708db2e8..bb0e0982d4 100644 --- a/tools/internal/contract-state-importer/importer-cli/Cargo.toml +++ b/tools/internal/contract-state-importer/importer-cli/Cargo.toml @@ -22,7 +22,7 @@ tracing = { workspace = true } importer-contract = { path = "../importer-contract" } nym-validator-client = { path = "../../../../common/client-libs/validator-client" } -nym-bin-common = { path = "../../../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../../../common/bin-common" } nym-network-defaults = { path = "../../../../common/network-defaults" } nym-mixnet-contract-common = { path = "../../../../common/cosmwasm-smart-contracts/mixnet-contract" } diff --git a/tools/internal/contract-state-importer/importer-cli/src/main.rs b/tools/internal/contract-state-importer/importer-cli/src/main.rs index 6962f3c092..cabb3ae36b 100644 --- a/tools/internal/contract-state-importer/importer-cli/src/main.rs +++ b/tools/internal/contract-state-importer/importer-cli/src/main.rs @@ -3,7 +3,7 @@ use crate::commands::Cli; use clap::Parser; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use nym_network_defaults::setup_env; pub mod commands; @@ -15,6 +15,6 @@ async fn main() -> anyhow::Result<()> { let cli = Cli::parse(); setup_env(cli.config_env_file.as_ref()); - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); cli.execute().await } diff --git a/tools/internal/mixnet-connectivity-check/Cargo.toml b/tools/internal/mixnet-connectivity-check/Cargo.toml index af55790aa4..320c2e360e 100644 --- a/tools/internal/mixnet-connectivity-check/Cargo.toml +++ b/tools/internal/mixnet-connectivity-check/Cargo.toml @@ -18,6 +18,6 @@ tracing = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "signal", "macros"] } nym-network-defaults = { path = "../../../common/network-defaults" } -nym-bin-common = { path = "../../../common/bin-common", features = ["basic_tracing", "output_format"] } +nym-bin-common = { path = "../../../common/bin-common", features = ["output_format"] } nym-crypto = { path = "../../../common/crypto", features = ["asymmetric"] } nym-sdk = { path = "../../../sdk/rust/nym-sdk" } diff --git a/tools/internal/mixnet-connectivity-check/src/main.rs b/tools/internal/mixnet-connectivity-check/src/main.rs index 4dd68a61ab..f41c1f5c97 100644 --- a/tools/internal/mixnet-connectivity-check/src/main.rs +++ b/tools/internal/mixnet-connectivity-check/src/main.rs @@ -152,7 +152,7 @@ async fn main() -> anyhow::Result<()> { let args = Cli::parse(); setup_env(args.config_env_file.as_ref()); - // setup_tracing_logger(); + // setup_no_otel_logger().expect("failed to initialize logging"); args.execute().await } diff --git a/tools/internal/testnet-manager/Cargo.toml b/tools/internal/testnet-manager/Cargo.toml index 6f799d84a4..4c1fdc2d9a 100644 --- a/tools/internal/testnet-manager/Cargo.toml +++ b/tools/internal/testnet-manager/Cargo.toml @@ -32,7 +32,7 @@ url.workspace = true zeroize = { workspace = true, features = ["zeroize_derive"] } -nym-bin-common = { path = "../../../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../../../common/bin-common", features = ["output_format"] } nym-crypto = { path = "../../../common/crypto", features = ["asymmetric", "rand", "serde"] } nym-config = { path = "../../../common/config" } nym-validator-client = { path = "../../../common/client-libs/validator-client" } diff --git a/tools/internal/testnet-manager/src/main.rs b/tools/internal/testnet-manager/src/main.rs index 49d93a46dc..583bb4feee 100644 --- a/tools/internal/testnet-manager/src/main.rs +++ b/tools/internal/testnet-manager/src/main.rs @@ -18,7 +18,7 @@ mod manager; async fn main() -> anyhow::Result<()> { use crate::cli::Cli; use clap::Parser; - use nym_bin_common::logging::setup_tracing_logger; + use nym_bin_common::logging::setup_no_otel_logger; // std::env::set_var( // "RUST_LOG", @@ -26,7 +26,7 @@ async fn main() -> anyhow::Result<()> { // ); let cli = Cli::parse(); - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); cli.execute().await?; diff --git a/tools/internal/validator-status-check/Cargo.toml b/tools/internal/validator-status-check/Cargo.toml index a0d09e336f..d271b14f0f 100644 --- a/tools/internal/validator-status-check/Cargo.toml +++ b/tools/internal/validator-status-check/Cargo.toml @@ -23,7 +23,7 @@ time = { workspace = true } nym-validator-client = { path = "../../../common/client-libs/validator-client" } -nym-bin-common = { path = "../../../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../../../common/bin-common", features = ["output_format"] } nym-network-defaults = { path = "../../../common/network-defaults" } nym-http-api-client = { path = "../../../common/http-api-client" } diff --git a/tools/internal/validator-status-check/src/main.rs b/tools/internal/validator-status-check/src/main.rs index 668aa5dd2b..764af1e4d1 100644 --- a/tools/internal/validator-status-check/src/main.rs +++ b/tools/internal/validator-status-check/src/main.rs @@ -3,7 +3,7 @@ use crate::commands::Cli; use clap::Parser; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use nym_network_defaults::setup_env; use tracing::trace; @@ -17,7 +17,7 @@ async fn main() -> anyhow::Result<()> { trace!("args: {cli:#?}"); setup_env(cli.config_env_file.as_ref()); - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); cli.execute().await?; Ok(()) diff --git a/tools/nym-cli/Cargo.toml b/tools/nym-cli/Cargo.toml index 8faf013dad..e7698c15c4 100644 --- a/tools/nym-cli/Cargo.toml +++ b/tools/nym-cli/Cargo.toml @@ -22,7 +22,7 @@ anyhow = { workspace = true } tap = { workspace = true } nym-cli-commands = { path = "../../common/commands" } -nym-bin-common = { path = "../../common/bin-common", features = ["basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common" } nym-validator-client = { path = "../../common/client-libs/validator-client", features = ["http-client"] } nym-network-defaults = { path = "../../common/network-defaults" } diff --git a/tools/nym-cli/src/main.rs b/tools/nym-cli/src/main.rs index b8315de641..dbc352cf48 100644 --- a/tools/nym-cli/src/main.rs +++ b/tools/nym-cli/src/main.rs @@ -3,7 +3,7 @@ use clap::{CommandFactory, Parser, Subcommand}; use log::{error, warn}; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use nym_cli_commands::context::{get_network_details, ClientArgs}; use nym_validator_client::nyxd::AccountId; @@ -147,7 +147,7 @@ async fn wait_for_interrupt() { #[tokio::main] async fn main() -> anyhow::Result<()> { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); let cli = Cli::parse(); diff --git a/tools/nym-id-cli/Cargo.toml b/tools/nym-id-cli/Cargo.toml index bada736bfd..c09cbc9907 100644 --- a/tools/nym-id-cli/Cargo.toml +++ b/tools/nym-id-cli/Cargo.toml @@ -17,6 +17,6 @@ clap = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tracing.workspace = true -nym-bin-common = { path = "../../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] } nym-credential-storage = { path = "../../common/credential-storage" } nym-id = { path = "../../common/nym-id" } diff --git a/tools/nym-id-cli/src/main.rs b/tools/nym-id-cli/src/main.rs index 8d8de30903..3ef79d7ee6 100644 --- a/tools/nym-id-cli/src/main.rs +++ b/tools/nym-id-cli/src/main.rs @@ -6,13 +6,13 @@ use crate::commands::Cli; use clap::Parser; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; mod commands; #[tokio::main] async fn main() -> anyhow::Result<()> { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); let cli = Cli::parse(); cli.execute().await diff --git a/tools/nym-nr-query/Cargo.toml b/tools/nym-nr-query/Cargo.toml index f5ec6f6475..8309e7e9c8 100644 --- a/tools/nym-nr-query/Cargo.toml +++ b/tools/nym-nr-query/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true anyhow = { workspace = true } clap = { workspace = true, features = ["cargo", "derive"]} log = { workspace = true } -nym-bin-common = { path = "../../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] } nym-network-defaults = { path = "../../common/network-defaults" } nym-sdk = { path = "../../sdk/rust/nym-sdk" } nym-service-providers-common = { path = "../../service-providers/common" } diff --git a/tools/nym-nr-query/src/main.rs b/tools/nym-nr-query/src/main.rs index aecf7110d0..3489abbeca 100644 --- a/tools/nym-nr-query/src/main.rs +++ b/tools/nym-nr-query/src/main.rs @@ -312,7 +312,7 @@ async fn main() -> anyhow::Result<()> { let args = Cli::parse(); if args.debug { - nym_bin_common::logging::setup_tracing_logger(); + nym_bin_common::logging::setup_no_otel_logger().expect("failed to initialize logging"); } nym_network_defaults::setup_env(args.config_env_file.as_ref()); diff --git a/tools/nymvisor/Cargo.toml b/tools/nymvisor/Cargo.toml index e1607edab0..320176ee0d 100644 --- a/tools/nymvisor/Cargo.toml +++ b/tools/nymvisor/Cargo.toml @@ -33,7 +33,7 @@ tracing = { workspace = true } url = { workspace = true, features = ["serde"] } nym-async-file-watcher = { path = "../../common/async-file-watcher" } -nym-bin-common = { path = "../../common/bin-common", features = ["output_format", "basic_tracing"] } +nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] } nym-config = { path = "../../common/config" } nym-task = { path = "../../common/task"} diff --git a/tools/nymvisor/src/cli/init.rs b/tools/nymvisor/src/cli/init.rs index 1382a6d1b3..a9247495aa 100644 --- a/tools/nymvisor/src/cli/init.rs +++ b/tools/nymvisor/src/cli/init.rs @@ -11,7 +11,7 @@ use crate::error::NymvisorError; use crate::helpers::init_path; use crate::upgrades::types::{CurrentVersionInfo, UpgradeInfo, UpgradePlan}; use nym_bin_common::build_information::BinaryBuildInformationOwned; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use nym_bin_common::output_format::OutputFormat; use std::fs; use std::path::{Path, PathBuf}; @@ -412,7 +412,7 @@ pub(crate) fn execute(args: Args) -> Result<(), NymvisorError> { let env = Env::try_read()?; if use_logs(args.disable_nymvisor_logs, &env) { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); info!("enabled nymvisor logging"); } diff --git a/tools/nymvisor/src/cli/run.rs b/tools/nymvisor/src/cli/run.rs index 14ec534ff2..b719db585f 100644 --- a/tools/nymvisor/src/cli/run.rs +++ b/tools/nymvisor/src/cli/run.rs @@ -7,7 +7,7 @@ use crate::error::NymvisorError; use crate::tasks::launcher::DaemonLauncher; use crate::tasks::upgrade_plan_watcher::start_upgrade_plan_watcher; use crate::tasks::upstream_poller::UpstreamPoller; -use nym_bin_common::logging::setup_tracing_logger; +use nym_bin_common::logging::setup_no_otel_logger; use std::future::Future; use std::time::Duration; use tokio::runtime; @@ -25,7 +25,7 @@ pub(crate) fn execute(args: Args) -> Result<(), NymvisorError> { let env = Env::try_read()?; let config = try_load_current_config(&env)?; if !config.nymvisor.debug.disable_logs { - setup_tracing_logger(); + setup_no_otel_logger().expect("failed to initialize logging"); } info!("starting nymvisor for {}", config.daemon.name);