Sha256: 726f99481a4eb5632224ee00b4627d17b850557c070803ab8c932125768b0284

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

# frozen_string_literal: true

require 'datadog/tracing/transport/io/client'

module InstrumentAllTheThings
  module Testing
    class TraceTracker < Datadog::Tracing::Transport::IO::Client
      attr_reader :traces

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

      def initialize(...)
        super
        reset!
      end

      def reset!
        @traces = []
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
instrument_all_the_things-5.0.1 lib/instrument_all_the_things/testing/trace_tracker.rb
instrument_all_the_things-5.0.0 lib/instrument_all_the_things/testing/trace_tracker.rb