Sha256: b27f53858fe8fde2b8872f5efa2c9f66b4af4b54b95322c29df3957248558cda

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require_relative '../../../metadata/ext'
require_relative '../../analytics'
require_relative '../ext'
require_relative '../event'

module Datadog
  module Tracing
    module Contrib
      module ActiveJob
        module Events
          # Defines instrumentation for enqueue_retry.active_job event
          module EnqueueRetry
            include ActiveJob::Event

            EVENT_NAME = 'enqueue_retry.active_job'

            module_function

            def event_name
              self::EVENT_NAME
            end

            def span_name
              Ext::SPAN_ENQUEUE_RETRY
            end

            def on_start(span, event, _id, payload)
              span.name = span_name
              span.service = configuration[:service_name] if configuration[:service_name]
              span.resource = payload[:job].class.name
              span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_ENQUEUE_RETRY)

              # Set analytics sample rate
              if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
                Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
              end

              set_common_tags(span, payload)
              span.set_tag(Ext::TAG_JOB_ERROR, payload[:error])
              span.set_tag(Ext::TAG_JOB_RETRY_WAIT, payload[:wait])
            rescue StandardError => e
              Datadog.logger.debug(e.message)
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
datadog-2.9.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.8.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.7.1 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.7.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.6.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.5.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.4.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.3.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb
datadog-2.2.0 lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb