Sha256: 938cd3634386d72300f86bfacc76626e9d2f3e6fce974af6aeb574f45c62c4da

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module StatsD::Instrument::Backends
  # The capture backend is used to capture the metrics that are collected, so you can
  # run assertions on them.
  #
  # @!attribute collected_metrics [r]
  #   @return [Array<StatsD::Instrument::Metric>] The list of metrics that were collected.
  # @see StatsD::Instrument::Assertions
  class CaptureBackend < StatsD::Instrument::Backend
    attr_reader :collected_metrics

    def initialize
      reset
    end

    # Adds a metric to the ist of collected metrics.
    # @param metric [StatsD::Instrument::Metric]  The metric to collect.
    # @return [void]
    def collect_metric(metric)
      @collected_metrics << metric
    end

    # Resets the list of collected metrics to an empty list.
    # @return [void]
    def reset
      @collected_metrics = []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
statsd-instrument-2.4.0 lib/statsd/instrument/backends/capture_backend.rb