diff --git a/api/lib/opentelemetry/context.rb b/api/lib/opentelemetry/context.rb index 42f12d3d7..05e96ed6b 100644 --- a/api/lib/opentelemetry/context.rb +++ b/api/lib/opentelemetry/context.rb @@ -113,8 +113,11 @@ def value(key) current.value(key) end + # Clears the fiber-local Context stack. This allocates a new array for the + # stack, which is important in some use-cases to avoid sharing the backing + # array between fibers. def clear - stack.clear + Thread.current[STACK_KEY] = [] end def empty