Class: OpenTelemetry::Internal::ProxyTracerProvider Private
- Inherits:
-
Trace::TracerProvider
- Object
- Trace::TracerProvider
- OpenTelemetry::Internal::ProxyTracerProvider
- Defined in:
- lib/opentelemetry/internal/proxy_tracer_provider.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
ProxyTracerProvider is an implementation of Trace::TracerProvider. It is the default global tracer provider returned by OpenTelemetry.tracer_provider. It delegates to a “real” TracerProvider after the global tracer provider is registered. It returns ProxyTracer instances until the delegate is installed.
Instance Method Summary collapse
-
#delegate=(provider) ⇒ Object
private
Set the delegate tracer provider.
-
#initialize ⇒ ProxyTracerProvider
constructor
private
Returns a new ProxyTracerProvider instance.
-
#tracer(name = nil, version = nil) ⇒ Tracer
private
Returns a Tracer instance.
Constructor Details
#initialize ⇒ ProxyTracerProvider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new OpenTelemetry::Internal::ProxyTracerProvider instance.
22 23 24 25 26 |
# File 'lib/opentelemetry/internal/proxy_tracer_provider.rb', line 22 def initialize @mutex = Mutex.new @registry = {} @delegate = nil end |
Instance Method Details
#delegate=(provider) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the delegate tracer provider. If this is called more than once, a warning will be logged and superfluous calls will be ignored.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/opentelemetry/internal/proxy_tracer_provider.rb', line 32 def delegate=(provider) unless @delegate.nil? OpenTelemetry.logger.warn 'Attempt to reset delegate in ProxyTracerProvider ignored.' return end @mutex.synchronize do @delegate = provider @registry.each { |key, tracer| tracer.delegate = provider.tracer(key.name, key.version) } end end |
#tracer(name = nil, version = nil) ⇒ Tracer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a Tracer instance.
50 51 52 53 54 55 56 |
# File 'lib/opentelemetry/internal/proxy_tracer_provider.rb', line 50 def tracer(name = nil, version = nil) @mutex.synchronize do return @delegate.tracer(name, version) unless @delegate.nil? @registry[Key.new(name, version)] ||= ProxyTracer.new end end |