Skip to content

Commit

Permalink
remove noop propagator from trilogy instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
plantfansam committed Feb 12, 2024
1 parent b409032 commit c0b8daf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0b8daf

Please sign in to comment.