Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/instrument_all_the_things/thread.rb

Overview

Class Method Summary collapse

Class Method Details

.new_tracedObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/instrument_all_the_things/thread.rb', line 7

def self.new_traced
  trace = Datadog::Tracing.active_trace

  if trace
    trace_digest = trace.to_digest
    Thread.new do |*args|
       # Inherits trace properties from the trace digest
      Datadog::Tracing.trace(trace.name, continue_from: trace_digest) do |_span, trace|
        trace.id == trace_digest.trace_id
        yield(*args)
      end
    end
  else
    Thread.new do |*args|
      yield(*args)
    end
  end
end