module OpenTelemetry::Instrumentation::RubyKafka::Patches::Producer

The Producer module contains the instrumentation patch the Producer#produce method

Public Instance Methods

produce(value, key: nil, headers: {}, topic:, partition: nil, partition_key: nil, create_time: Time.now) click to toggle source
Calls superclass method
# File lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb, line 13
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 Instance Methods

tracer() click to toggle source
# File lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb, line 28
def tracer
  RubyKafka::Instrumentation.instance.tracer
end