diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb index 5c6ed32bee..19932caa75 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb @@ -10,8 +10,7 @@ module ActiveJob module Handlers # Handles `enqueue.active_job` and `enqueue_at.active_job` to generate egress spans class Enqueue < Default - - # Overrides the `Default#start_span` method to create an ingress span + # Overrides the `Default#start_span` method to create an egress span # and registers it with the current context # # @param name [String] of the Event diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb index b54d75b387..50fa18e447 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb @@ -8,8 +8,15 @@ module OpenTelemetry module Instrumentation module ActiveJob module Handlers - # Handles perform.active_job + # Handles perform.active_job to geenrate ingress spans class Perform < Default + # Overrides the `Default#start_span` method to create an ingress span + # and registers it with the current context + # + # @param name [String] of the Event + # @param id [String] of the event + # @param payload [Hash] containing job run information + # @return [Hash] with the span and generated context tokens def start_span(name, _id, payload) tokens = [] parent_context = OpenTelemetry.propagation.extract(payload.fetch(:job).__otel_headers) @@ -50,6 +57,7 @@ def span_name_from(payload) "#{otel_config[:span_naming] == :job_class ? payload.fetch(:job).class.name : payload.fetch(:job).queue_name} process" end + # TODO: use dependency injection def otel_config ActiveJob::Instrumentation.instance.config end diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb index 20e7657d4d..021bb84a4a 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb @@ -26,7 +26,7 @@ def call(payload) 'messaging.message.id' => job.job_id, 'rails.active_job.execution.counter' => job.executions.to_i, 'rails.active_job.provider_job_id' => job.provider_job_id.to_s, - 'rails.active_job.priority' => job.priority, + 'rails.active_job.priority' => job.priority, # this can be problematic. Programs may use invalid attributes for priority. 'rails.active_job.scheduled_at' => job.scheduled_at&.to_f }