Skip to content

Commit 72e02aa

Browse files
committed
fix: Move telemetry suppression inside of the disconnected branch to avoid the added overhead of suppressing telemetry in the happy path
1 parent 96359fc commit 72e02aa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ impl Debug for BatchLogProcessor {
151151

152152
impl LogProcessor for BatchLogProcessor {
153153
fn emit(&self, record: &mut SdkLogRecord, instrumentation: &InstrumentationScope) {
154-
let _guard = Context::enter_telemetry_suppressed_scope();
155-
156154
let result = self
157155
.logs_sender
158156
.try_send(Box::new((record.clone(), instrumentation.clone())));
@@ -209,6 +207,10 @@ impl LogProcessor for BatchLogProcessor {
209207
}
210208
}
211209
Err(mpsc::TrySendError::Disconnected(_)) => {
210+
// The following `otel_warn!` may cause an infinite feedback loop of
211+
// 'telemetry-induced-telemetry', potentially causing a stack overflow
212+
let _guard = Context::enter_telemetry_suppressed_scope();
213+
212214
// Given background thread is the only receiver, and it's
213215
// disconnected, it indicates the thread is shutdown
214216
otel_warn!(

0 commit comments

Comments
 (0)