Sha256: c1655a9c336ef5f53b1d75a2e93d30be4af7307a695a4a9e1d7a3589152b31ca

Contents?: true

Size: 992 Bytes

Versions: 8

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module Rdkafka
      module Patches
        # The Producer module contains the instrumentation patch the Producer#produce method
        module Producer
          def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil)
            attributes = {
              'messaging.system' => 'kafka',
              'messaging.destination' => topic,
              'messaging.destination_kind' => 'topic'
            }

            headers ||= {}

            tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do
              OpenTelemetry.propagation.inject(headers)
              super
            end
          end

          private

          def tracer
            Rdkafka::Instrumentation.instance.tracer
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-rdkafka-0.3.2 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.3.1 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.3.0 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.2.3 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.2.2 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.2.1 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.2.0 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb
opentelemetry-instrumentation-rdkafka-0.1.0 lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb