Sha256: d0cf339944e0e1898c9b00ab6c839fc80744d8ad533d5daa4d7041e55f513045

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'deimos/tracing/provider'

module Deimos
  module Tracing
    # Tracing wrapper class for Datadog.
    class Datadog < Tracing::Provider
      # @param config [Hash]
      def initialize(config)
        raise 'Tracing config must specify service_name' if config[:service_name].nil?

        @service = config[:service_name]
      end

      # :nodoc:
      def start(span_name, options={})
        span = tracer.trace(span_name)
        span.service = @service
        span.resource = options[:resource]
        span
      end

      # :nodoc:
      def finish(span)
        span.finish
      end

      # :nodoc:
      def tracer
        @tracer ||= ::Datadog.respond_to?(:tracer) ? ::Datadog.tracer : ::Datadog::Tracing
      end

      # :nodoc:
      def active_span
        tracer.active_span
      end

      # :nodoc:
      def set_error(span, exception)
        span.set_error(exception)
      end

      # :nodoc:
      def set_tag(tag, value, span=nil)
        (span || active_span).set_tag(tag, value)
      end

      # :nodoc:
      def get_tag(tag)
        active_span.get_tag(tag)
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
deimos-ruby-2.0.0.pre.alpha2 lib/deimos/tracing/datadog.rb
deimos-ruby-2.0.0.pre.alpha1 lib/deimos/tracing/datadog.rb
deimos-ruby-1.24.2 lib/deimos/tracing/datadog.rb
deimos-ruby-1.24.1 lib/deimos/tracing/datadog.rb
deimos-ruby-1.24.0 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.3 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.2 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/tracing/datadog.rb
deimos-ruby-1.23.0 lib/deimos/tracing/datadog.rb