Skip to content

Commit dd11d5b

Browse files
authored
fix: Replace Context stack on clear (#1598)
* fix: Replace Context stack on clear * Document clear method
1 parent fee921b commit dd11d5b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

api/lib/opentelemetry/context.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ def value(key)
113113
current.value(key)
114114
end
115115

116+
# Clears the fiber-local Context stack. This allocates a new array for the
117+
# stack, which is important in some use-cases to avoid sharing the backing
118+
# array between fibers.
116119
def clear
117-
stack.clear
120+
Thread.current[STACK_KEY] = []
118121
end
119122

120123
def empty

0 commit comments

Comments
 (0)