Skip to content

Commit

Permalink
Make the tracer thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Aug 1, 2024
1 parent 211cbba commit 02fe448
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/diver_down/trace/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def stop
private

def build_trace_point
call_stack = DiverDown::Trace::CallStack.new
call_stacks = {}

TracePoint.new(*DiverDown::Trace::Tracer.trace_events) do |tp|
# Skip the trace of the library itself
next if tp.path&.start_with?(DiverDown::LIB_DIR)
next if TracePoint == tp.defined_class

call_stack = call_stacks[Thread.current] ||= DiverDown::Trace::CallStack.new

case tp.event
when :b_call
call_stack.push
Expand Down

0 comments on commit 02fe448

Please sign in to comment.