lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb in opentelemetry-instrumentation-sidekiq-0.5.0 vs lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb in opentelemetry-instrumentation-sidekiq-0.6.0
- old
+ new
@@ -7,23 +7,25 @@
module OpenTelemetry
module Instrumentation
module Sidekiq
module Middlewares
module Server
+ # TracerMiddleware propagates context and instruments Sidekiq requests
+ # by way of its middleware system
class TracerMiddleware
def call(_worker, msg, _queue)
parent_context = OpenTelemetry.propagation.text.extract(msg)
tracer.in_span(
msg['wrapped']&.to_s || msg['class'],
attributes: {
'messaging.message_id' => msg['jid'],
- 'messaging.destination' => msg['queue'],
+ 'messaging.destination' => msg['queue']
},
with_parent_context: parent_context,
kind: :consumer
) do |span|
- span.add_event(name: 'created_at', timestamp: msg['created_at'])
- span.add_event(name: 'enqueued_at', timestamp: msg['enqueued_at'])
+ span.add_event('created_at', timestamp: msg['created_at'])
+ span.add_event('enqueued_at', timestamp: msg['enqueued_at'])
yield
end
end
private