From 4847efdfe5cc163c19a1ed93ac624634b2c0ac72 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Tue, 3 Nov 2026 06:31:43 -0400 Subject: [PATCH] feat: add --enable-otel-metrics to export OpenTelemetry metrics from the workers --- cli/src/flags.rs | 5 +++++ cli/src/main.rs | 6 ++++++ crates/base/src/server.rs | 3 +++ 3 files changed, 14 insertions(+) diff --git a/cli/src/flags.rs b/cli/src/flags.rs index 136b3e0a9..393922835 100644 --- a/cli/src/flags.rs +++ b/cli/src/flags.rs @@ -329,6 +329,11 @@ fn get_start_command() -> Command { .default_missing_value("main,event") .action(ArgAction::Append), ) + .arg( + arg!(--"enable-otel-metrics") + .help("Also export OpenTelemetry metrics from the workers --enable-otel instruments") + .action(ArgAction::SetTrue), + ) .arg( arg!(--"otel-console" ) // .env("OTEL_DENO_CONSOLE") diff --git a/cli/src/main.rs b/cli/src/main.rs index 939dc6b5f..d561cd0d7 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -141,6 +141,11 @@ fn main() -> Result { .cloned() .collect::>(); + let otel_metrics = sub_matches + .get_one::("enable-otel-metrics") + .cloned() + .unwrap_or_default(); + let otel_console = sub_matches .get_one::("otel-console") .cloned() @@ -251,6 +256,7 @@ fn main() -> Result { } else { None }, + otel_metrics, otel_console, no_module_cache, diff --git a/crates/base/src/server.rs b/crates/base/src/server.rs index 0b33426d7..e9d50e305 100644 --- a/crates/base/src/server.rs +++ b/crates/base/src/server.rs @@ -328,6 +328,7 @@ impl RequestIdleTimeout { #[derive(Debug, Default, Clone, Copy)] pub struct ServerFlags { pub otel: Option, + pub otel_metrics: bool, pub otel_console: Option, pub no_module_cache: bool, @@ -467,6 +468,7 @@ impl Server { if let Some(OtelKind::Event | OtelKind::Both) = flags.otel { builder.set_otel_config(Some(OtelConfig { tracing_enabled: true, + metrics_enabled: flags.otel_metrics, console: flags.otel_console.unwrap_or_default(), propagators: HashSet::from([ OtelPropagators::TraceContext, @@ -522,6 +524,7 @@ impl Server { if let Some(OtelKind::Main | OtelKind::Both) = flags.otel { builder.set_otel_config(Some(OtelConfig { tracing_enabled: true, + metrics_enabled: flags.otel_metrics, console: flags.otel_console.unwrap_or_default(), propagators: HashSet::from([ OtelPropagators::TraceContext,