Skip to content

Commit 408ff96

Browse files
committed
chore: add log for invalid pops
1 parent 4d144f3 commit 408ff96

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

opentelemetry/src/context.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@ impl ContextStack {
460460
// The empty context is always at the bottom of the [`ContextStack`]
461461
// and cannot be popped, and the overflow position is invalid, so do
462462
// nothing.
463+
otel_warn!(
464+
name: "Context.PopInvalidPosition",
465+
position = pos,
466+
message = if pos == ContextStack::BASE_POS {
467+
"Attempted to pop the base context which is not allowed"
468+
} else {
469+
"Attempted to pop the overflow position which is not allowed"
470+
}
471+
);
463472
return;
464473
}
465474
let len: u16 = self.stack.len() as u16;
@@ -479,6 +488,12 @@ impl ContextStack {
479488
// This is an out of order pop.
480489
if pos >= len {
481490
// This is an invalid id, ignore it.
491+
otel_warn!(
492+
name: "Context.PopOutOfBounds",
493+
position = pos,
494+
stack_length = len,
495+
message = "Attempted to pop beyond the end of the context stack"
496+
);
482497
return;
483498
}
484499
// Clear out the entry at the given id.

0 commit comments

Comments
 (0)