class Datadog::ThreadLocalContext
ThreadLocalContext
can be used as a tracer global reference to create a different Context for each thread. In synchronous tracer, this is required to prevent multiple threads sharing the same Context in different executions.
Public Class Methods
new()
click to toggle source
ThreadLocalContext
can be used as a tracer global reference to create a different Context for each thread. In synchronous tracer, this is required to prevent multiple threads sharing the same Context in different executions.
To support multiple tracers simultaneously, each ThreadLocalContext instance has its own thread-local variable.
# File lib/ddtrace/context_provider.rb, line 34 def initialize @key = "datadog_context_#{object_id}".to_sym self.local = Datadog::Context.new end
Public Instance Methods
local()
click to toggle source
Return the thread-local context.
# File lib/ddtrace/context_provider.rb, line 46 def local Thread.current[@key] ||= Datadog::Context.new end
local=(ctx)
click to toggle source
Override the thread-local context with a new context.
# File lib/ddtrace/context_provider.rb, line 41 def local=(ctx) Thread.current[@key] = ctx end