Sha256: 5790c2c79bf780a33b4026d06d11ed7c14ef5a7ca2ec7dc7f9d36a2c066beaae

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

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

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

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

          private

          def tracer
            RubyKafka::Instrumentation.instance.tracer
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-ruby_kafka-0.20.1 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.20.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.19.1 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb