Sha256: ef1116bbdb349dbb115cb7c8ca1e1b0fad01a0a8a51066f972863c82cda43fcb

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

# typed: true

require_relative '../../ext'
require_relative '../../event'
require_relative '../../consumer_event'

module Datadog
  module Tracing
    module Contrib
      module Kafka
        module Events
          module Consumer
            # Defines instrumentation for process_message.consumer.kafka event
            module ProcessMessage
              include Kafka::Event
              extend Kafka::ConsumerEvent

              EVENT_NAME = 'process_message.consumer.kafka'.freeze

              def self.process(span, _event, _id, payload)
                super

                span.resource = payload[:topic]

                span.set_tag(Ext::TAG_TOPIC, payload[:topic]) if payload.key?(:topic)
                span.set_tag(Ext::TAG_MESSAGE_KEY, payload[:key]) if payload.key?(:key)
                span.set_tag(Ext::TAG_PARTITION, payload[:partition]) if payload.key?(:partition)
                span.set_tag(Ext::TAG_OFFSET, payload[:offset]) if payload.key?(:offset)
                span.set_tag(Ext::TAG_OFFSET_LAG, payload[:offset_lag]) if payload.key?(:offset_lag)
              end

              module_function

              def span_name
                Ext::SPAN_PROCESS_MESSAGE
              end

              def span_options
                super.merge({ tags: { Tracing::Metadata::Ext::TAG_OPERATION => Ext::TAG_OPERATION_PROCESS_MESSAGE } })
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.5.2 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.5.1 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.5.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.4.2 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.4.1 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.4.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb
ddtrace-1.3.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb