Skip to content

Commit

Permalink
fix: Replace Context stack on clear (#1598)
Browse files Browse the repository at this point in the history
* fix: Replace Context stack on clear

* Document clear method
  • Loading branch information
fbogsany authored Feb 15, 2024
1 parent fee921b commit dd11d5b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/lib/opentelemetry/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd11d5b

Please sign in to comment.