You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: streamline OTLP configuration and remove dead var (#82)
* chore: bump tracing-opentelemetry and otlp deps to compatible version
* refactor: streamline tracing and use env filter
* fix: ajj to published version
* fix: don't double filter
* chore: simplify init a bit
description:"OTLP level to export, defaults to DEBUG. Permissible values are: TRACE, DEBUG, INFO, WARN, ERROR, OFF",
107
-
optional:true,
108
-
},
109
-
&EnvItemInfo{
110
-
var:OTEL_TIMEOUT,
111
-
description:"OTLP timeout in milliseconds",
99
+
description:"OTLP level to export. Follows the RUST_LOG env filter format. e.g. `OTEL_LEVEL=warn,my_crate=info`. Defaults to the value of `RUST_LOG` if not present.",
112
100
optional:true,
113
101
},
114
102
&EnvItemInfo{
@@ -123,16 +111,22 @@ impl FromEnv for OtelConfig {
123
111
// load endpoint from env. ignore empty values (shortcut return None), parse, and print the error if any using inspect_err
124
112
let endpoint = Url::from_env_var(OTEL_ENDPOINT)?;
125
113
126
-
let level = tracing::Level::from_env_var(OTEL_LEVEL).unwrap_or(tracing::Level::DEBUG);
127
-
128
-
let timeout = Duration::from_env_var(OTEL_TIMEOUT).unwrap_or(Duration::from_millis(1000));
114
+
let level = if std::env::var(OTEL_LEVEL)
115
+
.as_ref()
116
+
.map(String::len)
117
+
.unwrap_or_default()
118
+
> 0
119
+
{
120
+
EnvFilter::from_env(OTEL_LEVEL)
121
+
}else{
122
+
EnvFilter::from_default_env()
123
+
};
129
124
130
125
let environment = String::from_env_var(OTEL_ENVIRONMENT).unwrap_or("unknown".into());
131
126
132
127
Ok(Self{
133
128
endpoint,
134
129
level,
135
-
timeout,
136
130
environment,
137
131
})
138
132
}
@@ -184,7 +178,19 @@ impl OtelConfig {
184
178
.with_batch_exporter(exporter)
185
179
.build();
186
180
187
-
OtelGuard(provider,self.level)
181
+
OtelGuard(provider,self.level.clone())
182
+
}
183
+
184
+
/// Create a new Otel provider, returning both the guard and a tracing
0 commit comments