Class: OpenTelemetry::SDK::Trace::TracerProvider
- Inherits:
-
Trace::TracerProvider
- Object
- Trace::TracerProvider
- OpenTelemetry::SDK::Trace::TracerProvider
- Defined in:
- lib/opentelemetry/sdk/trace/tracer_provider.rb
Overview
TracerProvider is the SDK implementation of Trace::TracerProvider.
Instance Attribute Summary collapse
-
#active_span_processor ⇒ Object
readonly
Returns the value of attribute active_span_processor.
-
#active_trace_config ⇒ Object
Returns the value of attribute active_trace_config.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#stopped ⇒ Object
(also: #stopped?)
readonly
Returns the value of attribute stopped.
Instance Method Summary collapse
-
#add_span_processor(span_processor) ⇒ Object
Adds a new SpanProcessor to this Tracer.
-
#initialize(resource = OpenTelemetry::SDK::Resources::Resource.create) ⇒ TracerProvider
constructor
Returns a new TracerProvider instance.
-
#shutdown(timeout: nil) ⇒ Object
Attempts to stop all the activity for this Tracer.
-
#tracer(name = nil, version = nil) ⇒ Tracer
Returns a Tracer instance.
Constructor Details
#initialize(resource = OpenTelemetry::SDK::Resources::Resource.create) ⇒ TracerProvider
Returns a new OpenTelemetry::SDK::Trace::TracerProvider instance.
22 23 24 25 26 27 28 29 30 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 22 def initialize(resource = OpenTelemetry::SDK::Resources::Resource.create) @mutex = Mutex.new @registry = {} @active_span_processor = NoopSpanProcessor.instance @active_trace_config = Config::TraceConfig::DEFAULT @registered_span_processors = [] @stopped = false @resource = resource end |
Instance Attribute Details
#active_span_processor ⇒ Object (readonly)
Returns the value of attribute active_span_processor.
16 17 18 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 16 def active_span_processor @active_span_processor end |
#active_trace_config ⇒ Object
Returns the value of attribute active_trace_config.
15 16 17 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 15 def active_trace_config @active_trace_config end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
16 17 18 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 16 def resource @resource end |
#stopped ⇒ Object (readonly) Also known as: stopped?
Returns the value of attribute stopped.
16 17 18 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 16 def stopped @stopped end |
Instance Method Details
#add_span_processor(span_processor) ⇒ Object
Adds a new SpanProcessor to this OpenTelemetry::SDK::Trace::Tracer.
Any registered processor causes overhead, consider to use an async/batch processor especially for span exporting, and export to multiple backends using the OpenTelemetry::SDK::Trace::TracerProvider.ioio.opentelemetryio.opentelemetry.sdkio.opentelemetry.sdk.traceio.opentelemetry.sdk.trace.exportio.opentelemetry.sdk.trace.export.MultiSpanExporter.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 73 def add_span_processor(span_processor) @mutex.synchronize do if @stopped OpenTelemetry.logger.warn('calling Tracer#add_span_processor after shutdown.') return end @registered_span_processors << span_processor @active_span_processor = MultiSpanProcessor.new(@registered_span_processors.dup) end end |
#shutdown(timeout: nil) ⇒ Object
Attempts to stop all the activity for this OpenTelemetry::SDK::Trace::Tracer. Calls SpanProcessor#shutdown for all registered SpanProcessors.
This operation may block until all the Spans are processed. Must be called before turning off the main application to ensure all data are processed and exported.
After this is called all the newly created Spans will be no-op.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 54 def shutdown(timeout: nil) @mutex.synchronize do if @stopped OpenTelemetry.logger.warn('calling Tracer#shutdown multiple times.') return end @active_span_processor.shutdown(timeout: timeout) @stopped = true end end |
#tracer(name = nil, version = nil) ⇒ Tracer
Returns a OpenTelemetry::SDK::Trace::Tracer instance.
38 39 40 41 42 |
# File 'lib/opentelemetry/sdk/trace/tracer_provider.rb', line 38 def tracer(name = nil, version = nil) name ||= '' version ||= '' @mutex.synchronize { @registry[Key.new(name, version)] ||= Tracer.new(name, version, self) } end |