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, attributes: 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 new OpenTelemetry::SDK::Trace::Tracer instance.

Parameters:

  • name (String)

    Instrumentation scope name

  • version (String)

    Instrumentation scope version

  • tracer_provider (TracerProvider)

    TracerProvider that initialized the tracer

  • attributes (Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    Instrumentation scope attributes



23
24
25
26
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 23

def initialize(name, version, tracer_provider, attributes: nil)
  @instrumentation_scope = InstrumentationScope.new(name, version, attributes || {}.freeze)
  @tracer_provider = tracer_provider
end

Instance Method Details

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



28
29
30
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 28

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



32
33
34
35
36
37
38
# File 'lib/opentelemetry/sdk/trace/tracer.rb', line 32

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

  @tracer_provider.internal_start_span(name, kind, attributes, links, start_timestamp, with_parent, @instrumentation_scope)
end