Sha256: 03246827dad6d577ce1cf0a88e20219a0dba8d3d6deddb4785d3446a118a3d50

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module Sidekiq
      module Patches
        # The Poller module contains instrumentation for the enqueue and wait methods
        module Poller
          def enqueue
            if instrumentation_config[:trace_poller_enqueue]
              attributes = {}
              attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service]
              tracer.in_span('Sidekiq::Scheduled::Poller#enqueue', attributes: attributes) { super }
            else
              OpenTelemetry::Common::Utilities.untraced { super }
            end
          end

          private

          def wait
            if instrumentation_config[:trace_poller_wait]
              tracer.in_span('Sidekiq::Scheduled::Poller#wait') { super }
            else
              OpenTelemetry::Common::Utilities.untraced { super }
            end
          end

          def tracer
            Sidekiq::Instrumentation.instance.tracer
          end

          def instrumentation_config
            Sidekiq::Instrumentation.instance.config
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-sidekiq-0.23.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.22.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.22.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.21.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb