Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ anyhow = { default-features = false, version = "1.0" }
async-trait = { version = "0.1" }
base64 = { version = "0.22" }
chrono = { features = ["serde"], version = "0.4" }
clap = { features = ["derive"], version = "4.5" }
clap = { features = ["derive", "env"], version = "4.5" }
deadpool = { default-features = false, features = ["managed", "rt_tokio_1"], version = "0.12" }
deadpool-sync = { version = "0.1" }
fs-err = { version = "3" }
Expand Down
4 changes: 2 additions & 2 deletions bin/node/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ services:
- "57292:57292" # gRPC
- "9091:9090" # Health checks
environment:
- OTEL_ENABLED=true
- MIDEN_TLNODE_ENABLE_OTEL=true
- JSON_LOGGING=true
- OTEL_TRACES_ENDPOINT=http://otel-collector:4317
- MIDEN_TLNODE_OTEL_ENDPOINT=http://otel-collector:4317
- OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
- OTEL_SERVICE_NAME=miden-note-transport-node
- RUST_LOG=INFO
Expand Down
14 changes: 13 additions & 1 deletion bin/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ struct Args {
/// Connection timeout in seconds
#[arg(long, default_value = "4")]
request_timeout: usize,

/// Enable OpenTelemetry tracing and metrics export
#[arg(long, env = "MIDEN_TLNODE_ENABLE_OTEL", default_value = "false")]
enable_otel: bool,

/// OpenTelemetry OTLP endpoint
#[arg(
long,
env = "MIDEN_TLNODE_OTEL_ENDPOINT",
default_value = "http://localhost:4317"
)]
otel_endpoint: String,
}

#[tokio::main]
Expand All @@ -44,7 +56,7 @@ async fn main() -> Result<()> {
let args = Args::parse();

// Setup tracing
let tracing_cfg = TracingConfig::from_env();
let tracing_cfg = TracingConfig::new(args.enable_otel, args.otel_endpoint.clone());
setup_tracing(tracing_cfg.clone())?;

info!("Starting Miden Transport Node...");
Expand Down
22 changes: 6 additions & 16 deletions crates/node/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,12 @@ pub enum OpenTelemetry {
}

impl TracingConfig {
/// Tracing configuration constructor using environment variables
pub fn from_env() -> Self {
let otel = {
let otel_enabled = std::env::var("OTEL_ENABLED")
.unwrap_or_else(|_| "false".to_string())
.parse()
.unwrap_or(false);
if otel_enabled {
OpenTelemetry::Enabled {
endpoint: std::env::var("OTEL_TRACES_ENDPOINT")
.ok()
.unwrap_or("http://localhost:4317".to_string()),
}
} else {
OpenTelemetry::Disabled
}
/// Create a new tracing configuration with explicit parameters.
pub fn new(enable_otel: bool, otel_endpoint: String) -> Self {
let otel = if enable_otel {
OpenTelemetry::Enabled { endpoint: otel_endpoint }
} else {
OpenTelemetry::Disabled
};

TracingConfig {
Expand Down
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ allow = [
"FTL",
"ISC",
"JSON",
"LGPL-3.0-or-later",
"MIT",
"MPL-2.0",
"MS-PL",
"OpenSSL",
"PostgreSQL",
Expand Down
Loading