Class: StatsD::Instrument::CaptureSink

Inherits:
Object
  • Object
show all
Defined in:
lib/statsd/instrument/capture_sink.rb

Overview

Note:

This class is part of the new Client implementation that is intended to become the new default in the next major release of this library.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent:, datagram_class: StatsD::Instrument::Datagram) ⇒ CaptureSink

Returns a new instance of CaptureSink.



10
11
12
13
14
# File 'lib/statsd/instrument/capture_sink.rb', line 10

def initialize(parent:, datagram_class: StatsD::Instrument::Datagram)
  @parent = parent
  @datagram_class = datagram_class
  @datagrams = []
end

Instance Attribute Details

#datagram_classObject (readonly)

Returns the value of attribute datagram_class.



8
9
10
# File 'lib/statsd/instrument/capture_sink.rb', line 8

def datagram_class
  @datagram_class
end

#datagramsObject (readonly)

Returns the value of attribute datagrams.



8
9
10
# File 'lib/statsd/instrument/capture_sink.rb', line 8

def datagrams
  @datagrams
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/statsd/instrument/capture_sink.rb', line 8

def parent
  @parent
end

Instance Method Details

#<<(datagram) ⇒ Object



20
21
22
23
24
# File 'lib/statsd/instrument/capture_sink.rb', line 20

def <<(datagram)
  @datagrams << datagram_class.new(datagram)
  parent << datagram
  self
end

#clearObject



26
27
28
# File 'lib/statsd/instrument/capture_sink.rb', line 26

def clear
  @datagrams.clear
end

#flush(blocking:) ⇒ Object



30
31
32
# File 'lib/statsd/instrument/capture_sink.rb', line 30

def flush(blocking:)
  @parent.flush(blocking: blocking)
end

#sample?(_sample_rate) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/statsd/instrument/capture_sink.rb', line 16

def sample?(_sample_rate)
  true
end