Sha256: fb836910641a29b25ed2cb4b43c87d80932fe8bb2f6750e73ab61131576896ab

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 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 config[:trace_poller_enqueue]
              attributes = {}
              attributes['peer.service'] = config[:peer_service] if 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 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 config
            Sidekiq::Instrumentation.instance.config
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-sidekiq-0.21.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.20.2 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.20.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.20.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.19.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.19.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.18.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.17.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb