Sha256: 967ea6e0f622b36675cd870cddad6f3044f96ddcc34db08ab78a8b6ccbf9f932
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module Instrumentation module Sidekiq module Middlewares module Client # TracerMiddleware propagates context and instruments Sidekiq client # by way of its middleware system class TracerMiddleware def call(_worker_class, job, _queue, _redis_pool) tracer.in_span( span_name(job), attributes: { 'messaging.system' => 'sidekiq', 'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'], 'messaging.message_id' => job['jid'], 'messaging.destination' => job['queue'], 'messaging.destination_kind' => 'queue' }, kind: :producer ) do |span| OpenTelemetry.propagation.inject(job) span.add_event('created_at', timestamp: job['created_at']) yield end end private def span_name(job) if config[:enable_job_class_span_names] "#{job['wrapped']&.to_s || job['class']} enqueue" else "#{job['queue']} send" end end def config Sidekiq::Instrumentation.instance.config end def tracer Sidekiq::Instrumentation.instance.tracer end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems