Class: Sbmt::KafkaProducer::Instrumentation::OpenTelemetryTracer
- Inherits:
-
Object
- Object
- Sbmt::KafkaProducer::Instrumentation::OpenTelemetryTracer
- Defined in:
- lib/sbmt/kafka_producer/instrumentation/open_telemetry_tracer.rb
Class Attribute Summary collapse
-
.enabled ⇒ Object
writeonly
Sets the attribute enabled.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.enabled=(value) ⇒ Object (writeonly)
Sets the attribute enabled
12 13 14 |
# File 'lib/sbmt/kafka_producer/instrumentation/open_telemetry_tracer.rb', line 12 def enabled=(value) @enabled = value end |
Class Method Details
.enabled? ⇒ Boolean
8 9 10 |
# File 'lib/sbmt/kafka_producer/instrumentation/open_telemetry_tracer.rb', line 8 def enabled? !!@enabled end |
Instance Method Details
#call(message) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sbmt/kafka_producer/instrumentation/open_telemetry_tracer.rb', line 19 def call() return unless enabled? topic = [:topic] attributes = { "messaging.system" => "kafka", "messaging.destination" => topic, "messaging.destination_kind" => "topic" } = ([:key]) attributes["messaging.kafka.message_key"] = if [:headers] ||= {} tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do ::OpenTelemetry.propagation.inject([:headers]) end end |
#enabled? ⇒ Boolean
15 16 17 |
# File 'lib/sbmt/kafka_producer/instrumentation/open_telemetry_tracer.rb', line 15 def enabled? self.class.enabled? end |