Class: OpenTelemetry::Instrumentation::DelayedJob::Plugins::TracerPlugin
- Inherits:
-
Delayed::Plugin
- Object
- Delayed::Plugin
- OpenTelemetry::Instrumentation::DelayedJob::Plugins::TracerPlugin
- 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 27 28 |
# File 'lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb', line 16 def instrument_enqueue(job, &block) return yield(job) unless enabled? attributes = build_attributes(job) attributes['messaging.operation'] = 'publish' attributes.compact! tracer.in_span("#{job_queue(job)} publish", 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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb', line 30 def instrument_invoke(job, &block) return yield(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 attributes.compact! tracer.in_span("#{job_queue(job)} process", attributes: attributes, kind: :consumer) do |span| add_events(span, job) yield job end end |