Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(doppler): rust log (#4334)

Will Hutchinsonad4ac507f55e
diff --git a/rust/cloud-storage/macro_entrypoint/src/lib.rs b/rust/cloud-storage/macro_entrypoint/src/lib.rs
index ed0ea1bf80..131a6e223a 100644
--- a/rust/cloud-storage/macro_entrypoint/src/lib.rs
+++ b/rust/cloud-storage/macro_entrypoint/src/lib.rs
@@ -5,7 +5,7 @@
mod datadog_fmt;
use macro_env::Environment;
-use macro_env_var::env_vars;
+use macro_env_var::{env_vars, maybe_env_var};
use opentelemetry::trace::TracerProvider as _;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::trace::SdkTracerProvider;
@@ -17,6 +17,23 @@ env_vars! {
pub struct DdEnv;
}
+maybe_env_var! {
+ pub struct RustLog;
+}
+
+/// Build an [`EnvFilter`] from `RUST_LOG`, honoring values injected via `APP_SECRETS_JSON`.
+///
+/// [`EnvFilter::from_default_env`] only reads the process environment, so a `RUST_LOG` set through
+/// `APP_SECRETS_JSON` (the way the rest of our config is injected, see `macro_env_var`) is ignored
+/// and our tracing filter ends up wrong. This reads `RUST_LOG` the same way `macro_env_var` does —
+/// `APP_SECRETS_JSON` first, then the process environment as a fallback.
+fn rust_log_env_filter() -> EnvFilter {
+ match RustLog::new() {
+ Some(value) => EnvFilter::builder().parse_lossy(value),
+ None => EnvFilter::from_default_env(),
+ }
+}
+
/// unit struct which defines the behaviour for instantiation
#[derive(Debug)]
pub struct MacroEntrypoint {
@@ -72,7 +89,7 @@ impl MacroEntrypoint {
(Environment::Local, LocalOptions { tree_tracing: None }) => {
tracing_subscriber::fmt()
.with_ansi(true)
- .with_env_filter(EnvFilter::from_default_env())
+ .with_env_filter(rust_log_env_filter())
.with_file(true)
.with_line_number(true)
.pretty()
@@ -120,7 +137,7 @@ impl MacroEntrypoint {
.event_format(datadog_fmt::DatadogFormat { inner: json_format });
Registry::default()
- .with(EnvFilter::from_default_env())
+ .with(rust_log_env_filter())
.with(fmt_layer)
.with(otel_layer)
.init();