Class: OpenTelemetry::SDK::Trace::Tracer

Inherits:
Trace::Tracer
  • Object
show all
Defined in:
lib/opentelemetry/sdk/trace/tracer.rb

Overview

Tracer is the SDK implementation of Trace::Tracer.

Instance Method Summary collapse

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.

Parameters:

  • name (String)

    Instrumentation package name

  • version (String)

    Instrumentation package version

  • tracer_provider (TracerProvider)

    TracerProvider that initialized the tracer



21
22
23
24
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 21

def initialize(name, version, tracer_provider)
  @instrumentation_library = InstrumentationLibrary.new(name, version)
  @tracer_provider = tracer_provider
end

Instance Method Details

#start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object



26
27
28
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 26

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: start_timestamp, kind: kind)
end

#start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 30

def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
  name ||= 'empty'

  with_parent ||= Context.current
  parent_span = OpenTelemetry::Trace.current_span(with_parent)
  parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
  if parent_span_context.valid?
    parent_span_id = parent_span_context.span_id
    trace_id = parent_span_context.trace_id
  end

  @tracer_provider.internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, with_parent, parent_span, @instrumentation_library)
end