Skip to content

Commit ef37f5f

Browse files
committed
fix: deepsource
1 parent 5a2b128 commit ef37f5f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/telemetry.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ use opentelemetry_sdk::{
2525
trace::{BatchSpanProcessor, SdkTracerProvider},
2626
};
2727

28+
const EXPORTER_OTLP_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_ENDPOINT";
29+
const EXPORTER_OTLP_PROTOCOL: &str = "OTEL_EXPORTER_OTLP_PROTOCOL";
30+
2831
/// Initialise an OTLP tracer provider.
2932
///
3033
/// **Required env var:**
@@ -48,10 +51,10 @@ use opentelemetry_sdk::{
4851
pub fn init_otel_tracer() -> Option<SdkTracerProvider> {
4952
// Only used to decide whether OTEL is enabled; the SDK reads it again
5053
// from env to build the exporter (which also appends /v1/traces for HTTP).
51-
std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").ok()?;
54+
std::env::var(EXPORTER_OTLP_ENDPOINT).ok()?;
5255

5356
let protocol =
54-
std::env::var("OTEL_EXPORTER_OTLP_PROTOCOL").unwrap_or_else(|_| "http/json".to_string());
57+
std::env::var(EXPORTER_OTLP_PROTOCOL).unwrap_or_else(|_| "http/json".to_string());
5558

5659
// Build the exporter using the SDK's env-var-aware builders.
5760
// We intentionally do NOT call .with_endpoint() / .with_headers() /

0 commit comments

Comments
 (0)