Module: OpenTelemetry::Instrumentation::Rdkafka::Patches::Producer

Defined in:
lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb', line 13

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