Sha256: 78192ca48accd3839d5f1d1f919e92ab22c14a35cc055e91fbd8b24f62164890

Contents?: true

Size: 620 Bytes

Versions: 8

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

require 'ddtrace'

# https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#between-threads
class Thread
  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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
instrument_all_the_things-4.0.0 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.1.2 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.1.2.pre1 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.1.1 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.1.0 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.1.0.pre1 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-3.0.0 lib/instrument_all_the_things/thread.rb
instrument_all_the_things-2.0.2 lib/instrument_all_the_things/thread.rb