Method: Datadog::Tracing::DefaultContextProvider#context
- Defined in:
- lib/datadog/tracing/context_provider.rb
#context(key = nil) ⇒ Object
Return the local context.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datadog/tracing/context_provider.rb', line 25 def context(key = nil) current_context = key.nil? ? @context.local : @context.local(key) # Rebuild/reset context after a fork # # We don't want forked processes to copy and retransmit spans # that were generated from the parent process. Reset it such # that it acts like a distributed trace. current_context.after_fork! do # TODO: Only assign to `self.context` when working on the current thread (`key == nil`) current_context = self.context = current_context.fork_clone end current_context end |