Module: OpenTelemetry::Instrumentation::ActiveJob

Extended by:
ActiveJob
Included in:
ActiveJob
Defined in:
lib/opentelemetry/instrumentation/active_job.rb,
lib/opentelemetry/instrumentation/active_job/version.rb,
lib/opentelemetry/instrumentation/active_job/handlers.rb,
lib/opentelemetry/instrumentation/active_job/patches/base.rb,
lib/opentelemetry/instrumentation/active_job/instrumentation.rb,
lib/opentelemetry/instrumentation/active_job/handlers/default.rb,
lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb,
lib/opentelemetry/instrumentation/active_job/handlers/perform.rb,
lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb

Overview

Contains the OpenTelemetry instrumentation for the ActiveJob gem

Defined Under Namespace

Modules: Handlers, Mappers, Patches Classes: Instrumentation

Constant Summary collapse

VERSION =
'0.7.1'

Instance Method Summary collapse

Instance Method Details

#context_with_span(span, parent_context: Context.current) ⇒ Object

Returns a context containing the span, derived from the optional parent context, or the current context if one was not provided.

Parameters:

  • context (optional Context)

    The context to use as the parent for the returned context



33
34
35
# File 'lib/opentelemetry/instrumentation/active_job.rb', line 33

def context_with_span(span, parent_context: Context.current)
  parent_context.set_value(CURRENT_SPAN_KEY, span)
end

#current_span(context = nil) ⇒ Object

Returns the current span from the current or provided context

Parameters:

  • context (optional Context) (defaults to: nil)

    The context to lookup the current Span from. Defaults to Context.current



23
24
25
26
# File 'lib/opentelemetry/instrumentation/active_job.rb', line 23

def current_span(context = nil)
  context ||= Context.current
  context.value(CURRENT_SPAN_KEY) || OpenTelemetry::Trace::Span::INVALID
end

#with_span(span) {|span, context| ... } ⇒ Object

Activates/deactivates the Span within the current Context, which makes the "current span" available implicitly.

On exit, the Span that was active before calling this method will be reactivated.

Parameters:

  • span (Span)

    the span to activate

Yields:

  • (span, context)

    yields span and a context containing the span to the block.



44
45
46
# File 'lib/opentelemetry/instrumentation/active_job.rb', line 44

def with_span(span)
  Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }
end