Class: Deimos::Tracing::Mock

Inherits:
Provider show all
Defined in:
lib/deimos/tracing/mock.rb

Overview

Class that mocks out tracing functionality

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil) ⇒ Mock

:nodoc:



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

def initialize(logger=nil)
  @logger = logger || Logger.new(STDOUT)
  @logger.info('MockTracingProvider initialized')
end

Instance Method Details

#active_spanObject

:nodoc:



33
34
35
# File 'lib/deimos/tracing/mock.rb', line 33

def active_span
  nil
end

#finish(span) ⇒ Object

:nodoc:



25
26
27
28
29
30
# File 'lib/deimos/tracing/mock.rb', line 25

def finish(span)
  name = span[:name]
  start = span[:started_at]
  finish = Time.zone.now
  @logger.info("Mock span '#{name}' finished: #{start} to #{finish}")
end

#set_error(span, exception) ⇒ Object

:nodoc:



43
44
45
46
47
# File 'lib/deimos/tracing/mock.rb', line 43

def set_error(span, exception)
  span[:exception] = exception
  name = span[:name]
  @logger.info("Mock span '#{name}' set an error: #{exception}")
end

#set_tag(name, value) ⇒ Object

:nodoc:



38
39
40
# File 'lib/deimos/tracing/mock.rb', line 38

def set_tag(name, value)
  nil
end

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

:nodoc:



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

def start(span_name, _options={})
  @logger.info("Mock span '#{span_name}' started")
  {
    name: span_name,
    started_at: Time.zone.now
  }
end