From 08f11aecd7e19bc50024f1979c3e6af4101b220a Mon Sep 17 00:00:00 2001 From: Ewan Whorton Date: Wed, 3 Jul 2024 16:32:14 +0100 Subject: [PATCH] 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 --- .../racecar/process_message_subscriber.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/process_message_subscriber.rb b/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/process_message_subscriber.rb index 31b5c8aa8..8b2f8392b 100644 --- a/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/process_message_subscriber.rb +++ b/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/process_message_subscriber.rb @@ -4,6 +4,13 @@ module OpenTelemetry module Instrumentation # This class contains the ASN subsciber that instruments message processing class ProcessMessageSubscriber + GETTER = if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.13.0') + Context::Propagation.text_map_getter + else + OpenTelemetry::Common::Propagation.symbol_key_getter + end + private_constant :GETTER + def tracer Racecar::Instrumentation.instance.tracer end @@ -11,7 +18,7 @@ def tracer def start(_name, _id, payload) attrs = attributes(payload) - parent_context = OpenTelemetry.propagation.extract(payload[:headers], getter: OpenTelemetry::Common::Propagation.symbol_key_getter) + parent_context = OpenTelemetry.propagation.extract(payload[:headers], getter: GETTER) parent_token = OpenTelemetry::Context.attach(parent_context) span_context = OpenTelemetry::Trace.current_span(parent_context).context