Sha256: 894053b4ead08f63e721a7697fa06bc6cedcf247de04a54fc90f2eb402d80cef

Contents?: true

Size: 967 Bytes

Versions: 12

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, key: nil, headers: {}, topic:, 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

12 entries across 12 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-ruby_kafka-0.19.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.6 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.5 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.4 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.3 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.2 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.1 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.18.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.17.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.16.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.15.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb
opentelemetry-instrumentation-ruby_kafka-0.14.0 lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb