Skip to content

Commit 08f11ae

Browse files
fix: suppress header access with symbol key deprecation warning in Racecar Instrumentation (#1040)
fix: suppress deprecation warning in Racecar Instrumentation Use the text_map_getter because accessing kafka message headers with a symbol key is now deprecated in rdkafka. Co-authored-by: Ariel Valentin <[email protected]>
1 parent b26b765 commit 08f11ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/process_message_subscriber.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ module OpenTelemetry
44
module Instrumentation
55
# This class contains the ASN subsciber that instruments message processing
66
class ProcessMessageSubscriber
7+
GETTER = if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.13.0')
8+
Context::Propagation.text_map_getter
9+
else
10+
OpenTelemetry::Common::Propagation.symbol_key_getter
11+
end
12+
private_constant :GETTER
13+
714
def tracer
815
Racecar::Instrumentation.instance.tracer
916
end
1017

1118
def start(_name, _id, payload)
1219
attrs = attributes(payload)
1320

14-
parent_context = OpenTelemetry.propagation.extract(payload[:headers], getter: OpenTelemetry::Common::Propagation.symbol_key_getter)
21+
parent_context = OpenTelemetry.propagation.extract(payload[:headers], getter: GETTER)
1522
parent_token = OpenTelemetry::Context.attach(parent_context)
1623

1724
span_context = OpenTelemetry::Trace.current_span(parent_context).context

0 commit comments

Comments
 (0)