dogstatsd-ruby 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/datadog/statsd/forwarder.rb +4 -2
- data/lib/datadog/statsd/sender.rb +8 -4
- data/lib/datadog/statsd/single_thread_sender.rb +4 -2
- data/lib/datadog/statsd/timer.rb +1 -0
- data/lib/datadog/statsd/version.rb +1 -1
- data/lib/datadog/statsd.rb +20 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92868c3d0ccb9a7847eaec3dd2da46413ab8acd2ce2df0008ee66c3e6500f3f6
|
4
|
+
data.tar.gz: 26064f00534e7df4a132d722041eea6b85a22849ca5c3c7caed05722320bcd9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f076b5aa76f4102f66698d5d19a3fbcd84e2b8b3a5fa944dcac07ddf8ee25f48a65d90e5296cbd7327f04dc90a8aba0234606bc50ab7c335120e9e17c3a6d2
|
7
|
+
data.tar.gz: e07f4469b7737fe7d67d32623194c90e09adf3d78ef0c26226bfed103db4067fa01e582f0627d426695dd9a0ff93c4e1e7d79d227bd5ce806d9ca28b2a440382
|
data/README.md
CHANGED
@@ -81,8 +81,6 @@ Version v5.x of `dogstatsd-ruby` is using a sender thread for flushing. This pro
|
|
81
81
|
|
82
82
|
If you are using [Sidekiq](https://github.com/mperham/sidekiq), please make sure to close the client instances that are instantiated. [See this example on using DogStatsD-ruby v5.x with Sidekiq](https://github.com/DataDog/dogstatsd-ruby/blob/master/examples/sidekiq_example.rb).
|
83
83
|
|
84
|
-
If you are using [Puma](https://github.com/puma/puma) or [Unicorn](https://yhbt.net/unicorn.git), please make sure to create the instance of DogStatsD in the workers, not in the main process before it forks to create its workers. See [this comment for more details](https://github.com/DataDog/dogstatsd-ruby/issues/179#issuecomment-845570345).
|
85
|
-
|
86
84
|
Applications that run into issues but can't apply these recommendations should use the `single_thread` mode which disables the use of the sender thread.
|
87
85
|
Here is how to instantiate a client in this mode:
|
88
86
|
|
@@ -25,11 +25,13 @@ module Datadog
|
|
25
25
|
)
|
26
26
|
@transport_type = connection_cfg.transport_type
|
27
27
|
|
28
|
-
if telemetry_flush_interval
|
29
|
-
|
28
|
+
@telemetry = if telemetry_flush_interval
|
29
|
+
Telemetry.new(telemetry_flush_interval,
|
30
30
|
global_tags: global_tags,
|
31
31
|
transport_type: @transport_type
|
32
32
|
)
|
33
|
+
else
|
34
|
+
nil
|
33
35
|
end
|
34
36
|
|
35
37
|
@connection = connection_cfg.make_connection(logger: logger, telemetry: telemetry)
|
@@ -20,8 +20,10 @@ module Datadog
|
|
20
20
|
@mx = Mutex.new
|
21
21
|
@queue_class = queue_class
|
22
22
|
@thread_class = thread_class
|
23
|
-
if flush_interval
|
24
|
-
|
23
|
+
@flush_timer = if flush_interval
|
24
|
+
Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) }
|
25
|
+
else
|
26
|
+
nil
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -102,10 +104,11 @@ module Datadog
|
|
102
104
|
# to close the sender nor trying to continue to `#add` more message
|
103
105
|
# into the sender.
|
104
106
|
def stop(join_worker: true)
|
107
|
+
@flush_timer.stop if @flush_timer
|
108
|
+
|
105
109
|
message_queue = @message_queue
|
106
110
|
message_queue.close if message_queue
|
107
111
|
|
108
|
-
@flush_timer.stop if @flush_timer
|
109
112
|
sender_thread = @sender_thread
|
110
113
|
sender_thread.join if sender_thread && join_worker
|
111
114
|
end
|
@@ -114,10 +117,11 @@ module Datadog
|
|
114
117
|
# to close the sender nor trying to continue to `#add` more message
|
115
118
|
# into the sender.
|
116
119
|
def stop(join_worker: true)
|
120
|
+
@flush_timer.stop if @flush_timer
|
121
|
+
|
117
122
|
message_queue = @message_queue
|
118
123
|
message_queue << :close if message_queue
|
119
124
|
|
120
|
-
@flush_timer.stop if @flush_timer
|
121
125
|
sender_thread = @sender_thread
|
122
126
|
sender_thread.join if sender_thread && join_worker
|
123
127
|
end
|
@@ -11,8 +11,10 @@ module Datadog
|
|
11
11
|
@message_buffer = message_buffer
|
12
12
|
@logger = logger
|
13
13
|
@mx = Mutex.new
|
14
|
-
if flush_interval
|
15
|
-
|
14
|
+
@flush_timer = if flush_interval
|
15
|
+
Datadog::Statsd::Timer.new(flush_interval) { flush }
|
16
|
+
else
|
17
|
+
nil
|
16
18
|
end
|
17
19
|
# store the pid for which this sender has been created
|
18
20
|
update_fork_pid
|
data/lib/datadog/statsd/timer.rb
CHANGED
data/lib/datadog/statsd.rb
CHANGED
@@ -237,6 +237,26 @@ module Datadog
|
|
237
237
|
send_stats(stat, value, DISTRIBUTION_TYPE, opts)
|
238
238
|
end
|
239
239
|
|
240
|
+
# Reports execution time of the provided block as a distribution.
|
241
|
+
#
|
242
|
+
# If the block fails, the stat is still reported, then the error
|
243
|
+
# is reraised
|
244
|
+
#
|
245
|
+
# @param [String] stat stat name.
|
246
|
+
# @param [Numeric] value distribution value.
|
247
|
+
# @param [Hash] opts the options to create the metric with
|
248
|
+
# @option opts [Numeric] :sample_rate sample rate, 1 for always
|
249
|
+
# @option opts [Array<String>] :tags An array of tags
|
250
|
+
# @example Report the time (in ms) taken to activate an account
|
251
|
+
# $statsd.distribution_time('account.activate') { @account.activate! }
|
252
|
+
def distribution_time(stat, opts = EMPTY_OPTIONS)
|
253
|
+
opts = { sample_rate: opts } if opts.is_a?(Numeric)
|
254
|
+
start = now
|
255
|
+
yield
|
256
|
+
ensure
|
257
|
+
distribution(stat, ((now - start) * 1000).round, opts)
|
258
|
+
end
|
259
|
+
|
240
260
|
# Sends a timing (in ms) for the given stat to the statsd server. The
|
241
261
|
# sample_rate determines what percentage of the time this report is sent. The
|
242
262
|
# statsd server then uses the sample_rate to correctly track the average
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogstatsd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rein Henrichs
|
8
8
|
- Karim Bogtob
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby DogStatsd client
|
15
15
|
email: code@datadoghq.com
|
@@ -44,9 +44,9 @@ licenses:
|
|
44
44
|
- MIT
|
45
45
|
metadata:
|
46
46
|
bug_tracker_uri: https://github.com/DataDog/dogstatsd-ruby/issues
|
47
|
-
changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.
|
48
|
-
documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.
|
49
|
-
source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.
|
47
|
+
changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.5.0/CHANGELOG.md
|
48
|
+
documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.5.0
|
49
|
+
source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.5.0
|
50
50
|
post_install_message: |2+
|
51
51
|
|
52
52
|
If you are upgrading from v4.x of the dogstatsd-ruby library, note the major change to the threading model:
|
@@ -66,8 +66,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
|
70
|
-
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.7.10
|
71
|
+
signing_key:
|
71
72
|
specification_version: 4
|
72
73
|
summary: A Ruby DogStatsd client
|
73
74
|
test_files: []
|
75
|
+
...
|