Skip to content

v5.2.0 / 2021.07.01

Compare
Choose a tag to compare
@remeh remeh released this 01 Jul 12:23
· 177 commits to master since this release
v5.2.0
f95552a
  • [FEATURE] Add single_thread mode for users having issues with the companion thread. #194 by @remeh

You can use this mode to avoid spawning a companion thread while using v5.x versions:

# Import the library
require 'datadog/statsd'

# Create a DogStatsD client instance.
statsd = Datadog::Statsd.new('localhost', 8125, single_thread: true)
...
# release resources used by the client instance and flush last metrics
statsd.close()

Note that if you want to restore the behavior of v4.x versions, you can also configure the buffer to flush on every metric submission:

# Import the library
require 'datadog/statsd'

# Create a DogStatsD client instance using UDP
statsd = Datadog::Statsd.new('localhost', 8125, single_thread: true, buffer_max_pool_size: 1)
...
# to close the instance is not necessary in this case since metrics are flushed on submission
# but it is still a good practice and it explicitely closes the socket
statsd.close()