Class: InstrumentAllTheThings::Testing::TraceTracker

Inherits:
Datadog::Tracing::Transport::IO::Client
  • Object
show all
Defined in:
lib/instrument_all_the_things/testing/trace_tracker.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraceTracker

Returns a new instance of TraceTracker.



17
18
19
20
# File 'lib/instrument_all_the_things/testing/trace_tracker.rb', line 17

def initialize(...)
  super
  reset!
end

Instance Attribute Details

#tracesObject (readonly)

Returns the value of attribute traces.



8
9
10
# File 'lib/instrument_all_the_things/testing/trace_tracker.rb', line 8

def traces
  @traces
end

Class Method Details

.trackerObject



10
11
12
13
14
15
# File 'lib/instrument_all_the_things/testing/trace_tracker.rb', line 10

def self.tracker
  @tracker ||= new(
    StringIO.new,
    Datadog::Core::Encoding::JSONEncoder,
  )
end

Instance Method Details

#reset!Object



22
23
24
# File 'lib/instrument_all_the_things/testing/trace_tracker.rb', line 22

def reset!
  @traces = []
end

#write_data(_, val) ⇒ Object



26
27
28
29
# File 'lib/instrument_all_the_things/testing/trace_tracker.rb', line 26

def write_data(_, val)
  body = JSON.parse(val)
  @traces.concat(body.fetch('traces', []).flatten)
end