diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb index cdb411b96..ef418e934 100644 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb +++ b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb @@ -7,22 +7,6 @@ module OpenTelemetry module Instrumentation module Trilogy - # @api private - class NoopPropagator - EMPTY_LIST = [].freeze - private_constant(:EMPTY_LIST) - - def inject(carrier, context: Context.current, setter: nil); end - - def extract(carrier, context: Context.current, getter: nil) - context - end - - def fields - EMPTY_LIST - end - end - # The Instrumentation class contains logic to detect and install the Trilogy instrumentation class Instrumentation < OpenTelemetry::Instrumentation::Base install do |config| @@ -61,10 +45,10 @@ def configure_propagator(config) propagator = config[:propagator] @propagator = case propagator when 'vitess' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Vitess') - when 'none', nil then NoopPropagator.new + when "none", nil + nil else OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured" - NoopPropagator.new end end diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb index fbfb6e65e..842a22075 100644 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb +++ b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb @@ -50,8 +50,11 @@ def query(sql) ), kind: :client ) do |_span, context| - sql = sql.dup unless !sql.frozen? || propagator.is_a?(OpenTelemetry::Instrumentation::Trilogy::NoopPropagator) - propagator.inject(sql, context: context) + if propagator + sql = sql.dup if sql.frozen? + propagator.inject(sql, context: context) + end + super(sql.freeze) end end