Method: Datadog::OpenTelemetry::API::Context::SingletonClass#attach

Defined in:
lib/datadog/opentelemetry/api/context.rb

#attach(context) ⇒ Object

Associates a Context with the caller’s current Fiber. Every call to this operation should be paired with a corresponding call to detach.

Returns a token to be used with the matching call to detach

Parameters:

  • context (Context)

    The new context

Returns:

  • (Object)

    A token to be used when detaching



110
111
112
113
114
115
116
# File 'lib/datadog/opentelemetry/api/context.rb', line 110

def attach(context)
  previous_trace = Tracing.active_trace
  continue_trace!(context)

  stack.push(previous_trace && previous_trace.otel_context || ::OpenTelemetry::Context::ROOT)
  stack.size
end