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(*args, **kwargs) ⇒ Object



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

def produce(*args, **kwargs)
  topic = kwargs[:topic]
  headers = kwargs[:headers] || {}
  attributes = {
    'messaging.system' => 'kafka',
    'messaging.destination' => topic,
    'messaging.destination_kind' => 'topic'
  }

  tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do
    OpenTelemetry.propagation.inject(headers)
    kwargs[:headers] = headers
    super
  end
end