Sha256: 17754b2b904e786a3c0eff1942de2eae26ee2e1a4731e70ca41d85466d78bdfb

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

# typed: true

require 'datadog/tracing/contrib/kafka/ext'
require 'datadog/tracing/contrib/kafka/event'
require 'datadog/tracing/contrib/kafka/consumer_event'

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

              EVENT_NAME = 'process_batch.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_COUNT, payload[:message_count]) if payload.key?(:message_count)
                span.set_tag(Ext::TAG_PARTITION, payload[:partition]) if payload.key?(:partition)
                if payload.key?(:highwater_mark_offset)
                  span.set_tag(Ext::TAG_HIGHWATER_MARK_OFFSET, payload[:highwater_mark_offset])
                end
                span.set_tag(Ext::TAG_OFFSET_LAG, payload[:offset_lag]) if payload.key?(:offset_lag)
              end

              module_function

              def span_name
                Ext::SPAN_PROCESS_BATCH
              end

              def span_options
                super.merge({ tags: { Tracing::Metadata::Ext::TAG_OPERATION => Ext::TAG_OPERATION_PROCESS_BATCH } })
              end
            end
          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/kafka/events/consumer/process_batch.rb
ddtrace-1.1.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb
ddtrace-1.0.0 lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb