fix(telemetry): console logs to WARN+ while logs go out over OTLP #579

Merged
sharang merged 1 commits from fix/console-logs-with-otlp into main 2026-10-29 11:58:26 +00:00
+9 -1
View File
@@ -13,6 +13,7 @@
//! | `OTEL_EXPORTER_OTLP_ENDPOINT` | OTLP collector endpoint (e.g. `https://otel.example.com`) | *(disabled)* |
//! | `OTEL_SERVICE_NAME` | Service name for resource | `service_name` param |
//! | `RUST_LOG` / standard `EnvFilter` | Log level filter | `info` |
//! | `LOG_CONSOLE` | Console (stdout) filter while OTLP export is on; the logs reach SigNoz via OTLP, so the console copy is only a fallback | `warn` |
use opentelemetry::global;
use opentelemetry::trace::TracerProvider as _;
@@ -123,9 +124,16 @@ pub fn init_telemetry(service_name: &str) -> TelemetryGuard {
.add_directive("h2=off".parse().unwrap_or_default())
.add_directive("reqwest=off".parse().unwrap_or_default());
// The OTLP log records are the copy SigNoz uses (structured, with
// severity and trace context). The node agent also ships stdout, so
// a full console copy would store every line twice; keep it to
// warnings and errors unless LOG_CONSOLE says otherwise.
let console_filter =
EnvFilter::try_from_env("LOG_CONSOLE").unwrap_or_else(|_| EnvFilter::new("warn"));
tracing_subscriber::registry()
.with(env_filter)
.with(fmt_layer)
.with(fmt_layer.with_filter(console_filter))
.with(otel_trace_layer)
.with(otel_log_layer.with_filter(otel_filter))
.init();