Class: Deimos::Tracing::Datadog

Inherits:
Provider
  • Object
show all
Defined in:
lib/deimos/tracing/datadog.rb

Overview

Tracing wrapper class for Datadog.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Datadog

Returns a new instance of Datadog.

Parameters:

  • config (Hash)


10
11
12
13
14
# File 'lib/deimos/tracing/datadog.rb', line 10

def initialize(config)
  raise 'Tracing config must specify service_name' if config[:service_name].nil?

  @service = config[:service_name]
end

Instance Method Details

#active_spanObject

:nodoc:



35
36
37
# File 'lib/deimos/tracing/datadog.rb', line 35

def active_span
  tracer.active_span
end

#finish(span) ⇒ Object

:nodoc:



25
26
27
# File 'lib/deimos/tracing/datadog.rb', line 25

def finish(span)
  span.finish
end

#get_tag(tag) ⇒ Object

:nodoc:



50
51
52
# File 'lib/deimos/tracing/datadog.rb', line 50

def get_tag(tag)
  active_span.get_tag(tag)
end

#set_error(span, exception) ⇒ Object

:nodoc:



40
41
42
# File 'lib/deimos/tracing/datadog.rb', line 40

def set_error(span, exception)
  span.set_error(exception)
end

#set_tag(tag, value, span = nil) ⇒ Object

:nodoc:



45
46
47
# File 'lib/deimos/tracing/datadog.rb', line 45

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

#start(span_name, options = {}) ⇒ Object

:nodoc:



17
18
19
20
21
22
# File 'lib/deimos/tracing/datadog.rb', line 17

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

#tracerObject

:nodoc:



30
31
32
# File 'lib/deimos/tracing/datadog.rb', line 30

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