Class: OpenTelemetry::Instrumentation::ActiveJob::Handlers::Enqueue
- Inherits:
-
Default
- Object
- Default
- OpenTelemetry::Instrumentation::ActiveJob::Handlers::Enqueue
- Defined in:
- lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb
Overview
Handles enqueue.active_job
and enqueue_at.active_job
to generate egress spans
Constant Summary collapse
- EVENT_NAME =
'publish'
Instance Method Summary collapse
-
#start_span(name, _id, payload) ⇒ Hash
Overrides the
Default#start_span
method to create an egress span and registers it with the current context.
Methods inherited from Default
#finish, #finish_span, #initialize, #on_exception, #start, #tracer
Constructor Details
This class inherits a constructor from OpenTelemetry::Instrumentation::ActiveJob::Handlers::Default
Instance Method Details
#start_span(name, _id, payload) ⇒ Hash
Overrides the Default#start_span
method to create an egress span
and registers it with the current context
22 23 24 25 26 27 28 29 |
# File 'lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb', line 22 def start_span(name, _id, payload) job = payload.fetch(:job) span_name = span_name(job, EVENT_NAME) span = tracer.start_span(span_name, kind: :producer, attributes: @mapper.call(payload)) token = OpenTelemetry::Context.attach(OpenTelemetry::Trace.context_with_span(span)) OpenTelemetry.propagation.inject(job.__otel_headers) # This must be transmitted over the wire { span: span, ctx_token: token } end |