Class: Datadog::Statsd::SingleThreadSender
- Inherits:
-
Object
- Object
- Datadog::Statsd::SingleThreadSender
- Defined in:
- lib/datadog/statsd/single_thread_sender.rb
Overview
The SingleThreadSender is a sender synchronously buffering messages in a ‘MessageBuffer`. It is using current Process.PID to check it is the result of a recent fork and it is reseting the MessageBuffer if that’s the case.
Instance Method Summary collapse
- #add(message) ⇒ Object
- #flush ⇒ Object
-
#initialize(message_buffer, logger: nil) ⇒ SingleThreadSender
constructor
A new instance of SingleThreadSender.
-
#rendez_vous ⇒ Object
Compatibility with ‘Sender`.
-
#start ⇒ Object
Compatibility with ‘Sender`.
-
#stop ⇒ Object
Compatibility with ‘Sender`.
Constructor Details
#initialize(message_buffer, logger: nil) ⇒ SingleThreadSender
Returns a new instance of SingleThreadSender.
10 11 12 13 14 15 16 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 10 def initialize(, logger: nil) = @logger = logger @mx = Mutex.new # store the pid for which this sender has been created update_fork_pid end |
Instance Method Details
#add(message) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 18 def add() @mx.synchronize { # we have just forked, meaning we have messages in the buffer that we should # not send, they belong to the parent process, let's clear the buffer. if forked? .reset update_fork_pid end .add() } end |
#flush ⇒ Object
30 31 32 33 34 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 30 def flush(*) @mx.synchronize { .flush() } end |
#rendez_vous ⇒ Object
Compatibility with ‘Sender`
45 46 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 45 def rendez_vous() end |
#start ⇒ Object
Compatibility with ‘Sender`
37 38 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 37 def start() end |
#stop ⇒ Object
Compatibility with ‘Sender`
41 42 |
# File 'lib/datadog/statsd/single_thread_sender.rb', line 41 def stop() end |