Sha256: 011a13cf9d7eea0968df92dd90cf2e29197d36e898effa09a71dfd61a908bb78

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

# typed: true

require 'yaml'

require 'datadog/core'
require 'datadog/tracing/contrib/sidekiq/ext'

module Datadog
  module Tracing
    module Contrib
      module Sidekiq
        # Common functionality used by both client-side and server-side tracers.
        module Tracing
          protected

          # If class is wrapping something else, the interesting resource info
          # is the underlying, wrapped class, and not the wrapper. This is
          # primarily to support `ActiveJob`.
          def job_resource(job)
            if job['wrapped']
              job['wrapped'].to_s
            elsif job['class'] == 'Sidekiq::Extensions::DelayedClass'
              delay_extension_class(job).to_s
            else
              job['class'].to_s
            end
          rescue => e
            Datadog.logger.debug { "Error retrieving Sidekiq job class name (jid:#{job['jid']}): #{e}" }

            job['class'].to_s
          end

          def delay_extension_class(job)
            clazz, method = YAML.parse(job['args'].first).children.first.children

            method = method.value[1..-1] # Remove leading `:` from method symbol

            "#{clazz.value}.#{method}"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddtrace-1.2.0 lib/datadog/tracing/contrib/sidekiq/tracing.rb
ddtrace-1.1.0 lib/datadog/tracing/contrib/sidekiq/tracing.rb
ddtrace-1.0.0 lib/datadog/tracing/contrib/sidekiq/tracing.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/contrib/sidekiq/tracing.rb