- [OTHER] Ruby versions 3.2 and 3.3 are now supported. #291 by @gdubicki
- [IMPROVEMENT] Reduce memory allocations during tag and metric serialization. #294 by @schlubbi
- [IMPROVEMENT] Avoid allocations when using delay_serialization. #295 by @jhawthorn
-
[FEATURE] Add the
delay_serialization
option, allowing users to delay expensive serialization until a more convenient time, such as after an HTTP request has completed. In multi-threaded mode, it causes serialization to happen inside the sender thread. #271 by @pudiva and @BlakeWilliams -
[FEATURE] Also, support the
sender_queue_size
insingle_thread
mode, so that it can benefit from the newdelay_serialization
option. Messages are now queued (possibly unserialized) untilsender_queue_size
is reached or#flush
is called. It may be set toFloat::INFINITY
, so that messages are indefinitely queued until an explicit#flush
. #271 by @pudiva and @BlakeWilliams -
[IMPROVEMENT] Add support of
DD_DOGSTATSD_URL
for configuration through environment variable. Valid formats are:udp://some-host
,udp://some-host:port
andunix:///path/to/unix.sock
.DD_DOGSTATSD_URL
has priority on other environment vars (DD_AGENT_HOST
,DD_DOGSTATSD_PORT
andDD_DOGSTATSD_SOCKET
) but does not throw an error if others are set, values are overridden instead. #278 by @remeh -
[BUGFIX] Fix NoMethodError when Datadog::Statsd is initialized without telemetry. #272 by @matthewshafer
-
[FEATURE] Add
distribution_time
method to facilitate measuring timing of a yielded block. #248 by @jordan-brough -
[BUGFIX] Stop flush timer before closing the queue #257 by @abicky
-
[IMPROVEMENT] Add a
pre_sampled
option to metric methods #235 by @matthewshafer -
[OTHER] Ruby versions earlier than 2.1.0 are no longer supported. Ruby-2.0 was EOL as of 2016-02-24.
-
[OTHER] Ruby versions 3.0 and 3.1 are now supported, including a fix for keyword arguments to
StatsD#open
. #240
-
[IMPROVEMENT] Add option "buffer_flush_interval" to flush buffered metrics #231 by @abicky
-
[IMPROVEMENT] Add Sender.queue_size limits to limit number of buffered metrics #232 by @djmitche
-
[IMPROVEMENT] The client can now be configured to use UDS via the
DD_DOGSTATSD_SOCKET
environment variable. This variable does not take precedence over any explicit parameters passed to the Statsd constructor. [#227][] by @djmitche
- [OTHER] restore connection opening behavior from before 5.3.0 (connections not opened on client instantiation but on the first write instead) #214 by @remeh
-
[ENHANCEMENT] Automatically re-allocate resources (e.g. background thread) if
dogstatsd-ruby
is used in an application using forks #205 by @remehThis will help in scenarios where applications are not handling cleanup/re-creation of the dogstatsd-ruby instances in forked processes. If you are an user of v4.x versions of
dogstatsd-ruby
and want to migrate to v5.x, please make sure to go through this section of the README and through the migration guide. -
[BUGFIX] Fix client telemetry in applications using forks #205 by @remeh
Please note that this version will emit a deprecation message if you are using ruby < 2.1
: we plan to drop support for ruby 2.0 in a future minor release.
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)
- [FEATURE] Flush last metrics on
Statsd#close
#180 by @kbogtob - [ENHANCEMENT] Do not try to flush where there is no available
message_queue
[#189][] by @remeh - [OTHER] Add pry to development dependencies and enable gem in Gemfile #192 by @ivoanjo
- [OTHER] Expand Ruby Support to Rubies 2.6, 2.7, and 3.0 [#191][] by @laserlemon
- If the DogStatsD client is instantiated before a
fork
, the forked process won't copy the companion thread that the original client needs to flush and the client won't work properly. This issue will be addressed in an upcoming version. If you are concerned by this issue, please read this section of the README.
- [OTHER] Re-introduce a
Statsd#batch
method to help with compatibility with v4.x versions: - [BUGFIX] Safely close concurrent resources on Sender #175 by @marcotc
API breaking changes
-
This new major version uses automatic buffering with preemptive flushing, there is no need to manually batch the metrics together anymore. The preemptive flushing part means that just before the buffer gets full, a flush is triggered. However, manual flush is still possible with the
Statsd#flush
method and is necessary to synchronously send your metrics. TheStatsd#batch
method has been deprecated from the API. -
Every instance of the client will spawn a companion thread for the new flush mechanism: it is important to close every instance using the method
Statsd#close
. -
As of (1), the metrics are now buffered before being sent on the network, you have to use the
Statsd#flush
method to force their sending through the socket. Note that the companion thread will automatically flush the buffered metrics if the buffer gets full or when you are closing the instance. -
Statsd#initialize
parametermax_buffer_bytes
has been renamed tobuffer_max_payload_size
for consistency with the new automatic batch strategy. Please note the addition ofbuffer_max_pool_size
to limit the maximum amount of messages to buffer.disable_telemetry
has been renamedtelemetry_enable
, please note the semantic inversion.
What would have been written this way with the v4 API:
require 'datadog/statsd'
statsd = Datadog::Statsd.new('127.0.0.1', 8125)
statsd.batch do |s|
s.increment('example_metric.increment', tags: ['environment:dev'])
s.gauge('example_metric.gauge', 123, tags: ['environment:dev'])
end
...
statsd.close()
should be written this way with the v5 API:
require 'datadog/statsd'
statsd = Datadog::Statsd.new('127.0.0.1', 8125)
statsd.increment('example_metric.increment', tags: ['environment:dev'])
statsd.gauge('example_metric.gauge', 123, tags: ['environment:dev'])
# synchronous flush
statsd.flush(sync: true)
...
statsd.close()
statsd.connection
should not be used anymore to get thehost
, theport
and thesocket_path
of the statsd connection, they are now available directly in thestatsd
object.
- [IMPROVEMENT] Use asynchronous IO to avoid doing IO in the hot paths of the library users #151 by @kbogtob
- [IMPROVEMENT] Automatic buffering/preemptive flushing for better performances #146 by @kbogtob
A version 4.9.0 containing changes intended for 5.0.0 (with API breaking changes) has been released and was available on 2021-03-23. It has been removed on 2021-03-24 and is not available anymore: v4.8.x should be used for latest v4 version of the gem, and v5.x.x versions should be used to benefit from the latest performances improvements.
- [FEATURE] Add
truncate_if_too_long
option to theevent
call to truncate the event if it is too long instead of raising an error #161 by @kazu9su
- [IMPROVEMENT] The overhead of submitting metrics through
dogstatsd-ruby
has been reduced #155 #156 by @marcotc
- [BUGFIX] Send global tags even if no tags provided when using service check / event call #147 by @f3ndot
- [FEATURE] Add support of more environment variables for tagging #140 by @delner
- [OTHER] Small optimizations [#139][] by @tenderlove
- [BUGFIX] Properly close UDPSocket before creating a new one #143 by @zachmccormick
- [OTHER] Refactor to make code more idiomatic #138 by @kbogtob
- [OTHER] Refactor to translate unit tests to rspec #135 by @kbogtob
- [OTHER] Bump rake requirement to >= 12.3.3 #137 by @remeh
- [FEATURE] Add configurable flush interval for the telemetry #132 by @hush-hush
- [OTHER] Code structure and tests improvements #131 by @kbogtob
- [FEATURE] Adding telemetry to the dogstatsd client #128 by @hush-hush
- [BUGFIX] Handle ECONNREFUSED and typo fix #113 by @redhotpenguin
- [BUGFIX] Allow Integer date_happened and timestamp options #115
- [OTHER] Update yard gem to 0.9.20 #114
- [FEATURE] Allow passing tags as a hash #107 by @jtzemp
- [FEATURE] Added a setting for the global sample rate #110 by @claytono
- [BUGFIX] Fix non-ascii event texts being truncated #112 by @devleoper
- [BUGFIX] Display error if
write
fails due to a bad socket #97 by @abicky
- [FEATURE] Added environment vars support for host, port and entity id #109 by @ahmed-mez
- [FEATURE] Handle ENOTCONN #102 by @blaines
- [IMPROVEMENT] Retry first before losing message when receiving ENOTCONN #104 by @blaines
- [IMPROVEMENT] Add
.open
for short-lived reporting that does not leave sockets around #96 by @grosser - [IMPROVEMENT] Extract batch logic into a class #95 by @grosser
- [IMPROVEMENT] Extract connection for separation of concerns #94 by @grosser
- [IMPROVEMENT] Fail fast on unknown options #93 by @grosser
- [IMPROVEMENT] Always lazy connect #92 by @grosser
- [IMPROVEMENT] Batch events and service checks too #88 by @grosser
- [IMPROVEMENT] Remove bad argument after options #83 by @grosser
- [IMPROVEMENT] Reduce object allocation and make all strings frozen on ruby 2.3+ #78 by @grosser
- Remove deprecated
version
method #91 by @grosser - port / host / tags / namespace can no longer be set on the instance to allow thread-safety #87 by @grosser
- port / host / socket_path readers are now on statsd.connection
- Make
logger
an instance var #90 by @grosser - Make
format_service_check
private #89 by @grosser - Improve code coverage / make
format_event
private #84 by @grosser - Set buffer size in bytes #86 by @grosser
- max_buffer_size initializer argument removed and replaced with max_buffer_bytes (defaults to 8192)
- max_buffer_size/max_buffer_size= methods removed
- [FEATURE] Add distribution support (beta). See #72.
- [IMPROVEMENT] A ton of cleanups and refinements courtesy of @grosser. See #68, #69, #73, #74, #75, #76, #77.
- [IMPROVEMENT] Unify tag handling in
format_service_check
. See #71 by @grosser. - [IMPROVEMENT] Use faster time method on ruby >= 2.1. See #70 by @grosser.
- [FEATURE] Add Unix Domain Socket support. #61, @sullerandras
- [IMPROVEMENT] Don't flush an empty buffer. #58, @misterbyrne
- [BUGFIX] Use defaults when host/port are nil. #56, @degemer
- [BUGFIX] Ignore nil tags and convert symbol. #53, @pschambacher
- [FEATURE] Nest batch calls. #52, @misterbyrne
- [BUGFIX] Convert tags to string type. #51, @jacobbednarz
- [FEATURE] Expose (socket) close method. #46, @ramfjord
- [IMPROVEMENT] Retry once when send fails on a closed socket. #46, @ramfjord
- [IMPROVEMENT] Use a instance variable to decide whether to batch or not. #47 @fimmtiu
Host resolution was previously done every time a message was sent, it is now
done once when Datadog::Statsd
is initiliazed (resulting in a non-negligible
performance improvement). #44, @AMekss
Datadog::Statsd.new(host, port)
will now raise a SocketError
if unable to
resolve the host
.
- [FEATURE] Add an optional
by
parameter for#increment
and#decrement
, #33 - [BUGFIX]
#time
: record on all block exits, #38 @nelhage - [IMPROVEMENT] Replace string literals with symbols or frozen strings, #37 @janester
The Statsd
is now namespaced under the Datadog module. #32 @djpate
To update:
require 'statsd'
->require 'datadog/statsd'
Statsd
->Datadog::Statsd
,
is now stripped from tags to avoid unexpected behavior. #34 @adimitrov
Datadog::Statsd
also validates that it receives an array of tags, and strips ,
and |
from them.
This release drops testing for Ruby 1.8.7. Future versions are likely to introduce backward incompatibilities with < Ruby 1.9.3.
- [FEATURE] Add service checks support, #11
- [FEATURE] Send time stat on failing block, #16 @gleseur
- [BUGFIX] Add instance tags to
Statsd.event
, #14 @gleseur - [OTHER] Use
send_stat
instead of overriding Rubysend
method, #17 @sensadrome - [OTHER] Changelog update
- [BUGFIX] Fixed bug in message separator when batching metrics
- [FEATURE] Added support for metrics batching
- [FEATURE] Added support for submitting events
- [FEATURE] Added global tags
- [FEATURE] Added ability to set namespace and tags from
Statsd#initialize
- [FEATURE] Added sets metrics
- Initial release