lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb in opentelemetry-instrumentation-sidekiq-0.16.0 vs lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb in opentelemetry-instrumentation-sidekiq-0.17.0
- old
+ new
@@ -14,26 +14,32 @@
class TracerMiddleware
def call(_worker, msg, _queue)
parent_context = OpenTelemetry.propagation.extract(msg)
tracer.in_span(
span_name(msg),
- attributes: {
- 'messaging.system' => 'sidekiq',
- 'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
- 'messaging.message_id' => msg['jid'],
- 'messaging.destination' => msg['queue'],
- 'messaging.destination_kind' => 'queue'
- },
+ attributes: build_attributes(msg),
with_parent: parent_context,
kind: :consumer
) do |span|
span.add_event('created_at', timestamp: msg['created_at'])
span.add_event('enqueued_at', timestamp: msg['enqueued_at'])
yield
end
end
private
+
+ def build_attributes(msg)
+ attributes = {
+ 'messaging.system' => 'sidekiq',
+ 'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
+ 'messaging.message_id' => msg['jid'],
+ 'messaging.destination' => msg['queue'],
+ 'messaging.destination_kind' => 'queue'
+ }
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
+ attributes
+ end
def span_name(msg)
if config[:enable_job_class_span_names]
"#{msg['wrapped']&.to_s || msg['class']} process"
else