Class: StatsD::Instrument::Backends::CaptureBackend

Inherits:
StatsD::Instrument::Backend show all
Defined in:
lib/statsd/instrument/backends/capture_backend.rb

Overview

The capture backend is used to capture the metrics that are collected, so you can run assertions on them.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCaptureBackend

Returns a new instance of CaptureBackend.



12
13
14
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 12

def initialize
  reset
end

Instance Attribute Details

#collected_metricsArray<StatsD::Instrument::Metric> (readonly)

Returns The list of metrics that were collected.

Returns:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 9

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

Instance Method Details

#collect_metric(metric) ⇒ void

This method returns an undefined value.

Adds a metric to the ist of collected metrics.

Parameters:



19
20
21
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 19

def collect_metric(metric)
  @collected_metrics << metric
end

#resetvoid

This method returns an undefined value.

Resets the list of collected metrics to an empty list.



25
26
27
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 25

def reset
  @collected_metrics = []
end