From a48e87e90e5d16518d77e8249dc87dd481eccddd Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 10 Oct 2023 21:36:35 -0500 Subject: [PATCH] refactor: Default to Proxy Tracer in instrumentations While working on https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/677, I ran into an issue where the base instrumentation tracer was not being automatically upgraded after the SDK initialization was complete. I am not sure why this was implemented this way but I figured other instrumentations would need a reference to a proxy tracer in the future. https://github.com/open-telemetry/opentelemetry-ruby/pull/671 --- instrumentation/base/lib/opentelemetry/instrumentation/base.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb index d944d1a6c..ccbc521fb 100644 --- a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb +++ b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb @@ -204,7 +204,7 @@ def initialize(name, version, install_blk, present_blk, @config = {} @installed = false @options = options - @tracer = OpenTelemetry::Trace::Tracer.new + @tracer = OpenTelemetry.tracer_provider.tracer(name, version) end # rubocop:enable Metrics/ParameterLists @@ -220,7 +220,6 @@ def install(config = {}) return false unless installable?(config) instance_exec(@config, &@install_blk) - @tracer = OpenTelemetry.tracer_provider.tracer(name, version) @installed = true end