Sha256: 8d368e0947e8e2aff9725f1c2f522c764702c8408cee9029dd9938d5b599fde1

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module SDK
    module Trace
      # {Tracer} is the SDK implementation of {OpenTelemetry::Trace::Tracer}.
      class Tracer < OpenTelemetry::Trace::Tracer
        # @api private
        #
        # Returns a new {Tracer} instance.
        #
        # @param [String] name Instrumentation package name
        # @param [String] version Instrumentation package version
        # @param [TracerProvider] tracer_provider TracerProvider that initialized the tracer
        #
        # @return [Tracer]
        def initialize(name, version, tracer_provider)
          @instrumentation_scope = InstrumentationScope.new(name, version)
          @tracer_provider = tracer_provider
        end

        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

        def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
          with_parent ||= Context.current
          return super(name, with_parent: with_parent, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind) if Common::Utilities.untraced?(with_parent)

          name ||= 'empty'
          kind ||= :internal

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opentelemetry-sdk-1.4.1 lib/opentelemetry/sdk/trace/tracer.rb
opentelemetry-sdk-1.4.0 lib/opentelemetry/sdk/trace/tracer.rb
opentelemetry-sdk-1.3.2 lib/opentelemetry/sdk/trace/tracer.rb
opentelemetry-sdk-1.3.1 lib/opentelemetry/sdk/trace/tracer.rb
opentelemetry-sdk-1.3.0 lib/opentelemetry/sdk/trace/tracer.rb
opentelemetry-sdk-1.2.1 lib/opentelemetry/sdk/trace/tracer.rb