Class: OpenTelemetry::Instrumentation::DelayedJob::Plugins::TracerPlugin

Inherits:
Delayed::Plugin
  • Object
show all
Defined in:
lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb

Overview

Delayed Job plugin that instruments invoke_job and other hooks

Class Method Summary collapse

Class Method Details

.instrument_enqueue(job, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb', line 16

def instrument_enqueue(job, &block)
  return block.call(job) unless enabled?

  attributes = build_attributes(job)
  attributes['messaging.operation'] = 'send'
  tracer.in_span("#{job_queue(job)} send", attributes: attributes, kind: :producer) do |span|
    yield job
    span.set_attribute('messaging.message_id', job.id.to_s)
    add_events(span, job)
  end
end

.instrument_invoke(job, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb', line 28

def instrument_invoke(job, &block)
  return block.call(job) unless enabled?

  attributes = build_attributes(job)
  attributes['messaging.delayed_job.attempts'] = job.attempts if job.attempts
  attributes['messaging.delayed_job.locked_by'] = job.locked_by if job.locked_by
  attributes['messaging.operation'] = 'process'
  attributes['messaging.message_id'] = job.id.to_s
  tracer.in_span("#{job_queue(job)} process", attributes: attributes, kind: :consumer) do |span|
    add_events(span, job)
    yield job
  end
end