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.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name, version) ⇒ Tracer
constructor
private
Returns a new Tracer instance.
- #start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil) ⇒ Object
-
#start_span(name, with_parent: nil, with_parent_context: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil) ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(name, version) ⇒ 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.
23 24 25 26 27 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 23 def initialize(name, version) @name = name @version = version @resource = Resources::Resource.create('name' => name, 'version' => version) 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 |
#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, sampling_hint: nil) ⇒ Object
29 30 31 32 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 29 def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil) parent_span_context = OpenTelemetry::Trace::SpanContext::INVALID start_span(name, with_parent_context: parent_span_context, attributes: attributes, links: links, start_timestamp: , kind: kind, sampling_hint: sampling_hint) end |
#start_span(name, with_parent: nil, with_parent_context: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil) ⇒ Object
rubocop:disable Metrics/AbcSize
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 34 def start_span(name, with_parent: nil, with_parent_context: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil) # rubocop:disable Metrics/AbcSize name ||= 'empty' parent_span_context = with_parent&.context || with_parent_context || current_span.context parent_span_context = nil unless parent_span_context.valid? parent_span_id = parent_span_context&.span_id tracestate = parent_span_context&.tracestate trace_id = parent_span_context&.trace_id trace_id ||= OpenTelemetry::Trace.generate_trace_id span_id = OpenTelemetry::Trace.generate_span_id sampler = OpenTelemetry.tracer_factory.active_trace_config.sampler result = sampler.call(trace_id: trace_id, span_id: span_id, parent_context: parent_span_context, hint: sampling_hint, links: links, name: name, kind: kind, attributes: attributes) internal_create_span(result, name, kind, trace_id, span_id, parent_span_id, attributes, links, , tracestate) end |