Class: OpenTelemetry::SDK::Trace::Tracer
- Inherits:
-
Trace::Tracer
- Object
- Trace::Tracer
- OpenTelemetry::SDK::Trace::Tracer
- Defined in:
- lib/opentelemetry/sdk/trace/tracer.rb
Overview
Tracer is the SDK implementation of Trace::Tracer.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tracer_provider ⇒ Object
readonly
Returns the value of attribute tracer_provider.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name, version, tracer_provider) ⇒ Tracer
constructor
private
Returns a new Tracer instance.
- #start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object
- #start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object
Constructor Details
#initialize(name, version, tracer_provider) ⇒ 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 new OpenTelemetry::SDK::Trace::Tracer instance.
25 26 27 28 29 30 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 25 def initialize(name, version, tracer_provider) @name = name @version = version @instrumentation_library = InstrumentationLibrary.new(name, version) @tracer_provider = tracer_provider end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 12 def name @name end |
#tracer_provider ⇒ Object (readonly)
Returns the value of attribute tracer_provider.
14 15 16 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 14 def tracer_provider @tracer_provider end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 13 def version @version end |
Instance Method Details
#start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object
32 33 34 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 32 def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil) start_span(name, with_parent: Context.empty, attributes: attributes, links: links, start_timestamp: , kind: kind) end |
#start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 36 def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) name ||= 'empty' with_parent ||= Context.current parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context if parent_span_context.valid? parent_span_id = parent_span_context.span_id tracestate = parent_span_context.tracestate trace_id = parent_span_context.trace_id end trace_id ||= OpenTelemetry::Trace.generate_trace_id sampler = tracer_provider.active_trace_config.sampler result = sampler.should_sample?(trace_id: trace_id, parent_context: with_parent, links: links, name: name, kind: kind, attributes: attributes) internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, , tracestate, with_parent) end |