Sha256: 301ed6c5415a3376b80d5208275f59d781455f35c2efd5460a3e4858535509cc

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 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[SemanticConventions::Trace::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

12 entries across 12 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-sidekiq-0.25.7 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.6 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.5 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.3 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.2 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.25.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.24.4 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.24.3 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.24.2 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.24.1 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
opentelemetry-instrumentation-sidekiq-0.24.0 lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb