Class: OpenTelemetry::Instrumentation::ActiveJob::Mappers::Attribute
- Inherits:
-
Object
- Object
- OpenTelemetry::Instrumentation::ActiveJob::Mappers::Attribute
- Defined in:
- lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb
Overview
Maps ActiveJob Attributes to Semantic Conventions
Instance Method Summary collapse
-
#call(payload) ⇒ Hash<String, Object>
Generates a set of attributes to add to a span using general and messaging semantic conventions as well as using
rails.active_job.*
namespace for custom attributes.
Instance Method Details
#call(payload) ⇒ Hash<String, Object>
Generates a set of attributes to add to a span using
general and messaging semantic conventions as well as
using rails.active_job.*
namespace for custom attributes
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/opentelemetry/instrumentation/active_job/mappers/attribute.rb', line 19 def call(payload) job = payload.fetch(:job) otel_attributes = { 'code.namespace' => job.class.name, 'messaging.system' => 'active_job', 'messaging.destination' => job.queue_name, 'messaging.message.id' => job.job_id, 'messaging.active_job.adapter.name' => job.class.queue_adapter_name } # Not all adapters generate or provide back end specific ids for messages otel_attributes['messaging.active_job.message.provider_job_id'] = job.provider_job_id.to_s if job.provider_job_id # This can be problematic if programs use invalid attribute types like Symbols for priority instead of using Integers. otel_attributes['messaging.active_job.message.priority'] = job.priority.to_s if job.priority otel_attributes.compact! otel_attributes end |