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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d780ad7a840c021ee3cb31a9e8b512ef7ccff4b82b14be9e300206d3a07cc61e
4
- data.tar.gz: 2da798fe3a84f313c5c84655136597c562e3dc1bfaa24f8ba6441ef722c7cc45
3
+ metadata.gz: 92868c3d0ccb9a7847eaec3dd2da46413ab8acd2ce2df0008ee66c3e6500f3f6
4
+ data.tar.gz: 26064f00534e7df4a132d722041eea6b85a22849ca5c3c7caed05722320bcd9e
5
5
  SHA512:
6
- metadata.gz: 8f92d7dab8099d571c291e26497020e53087ccdbeecfd84d955778f484112f9b94fb0f4ec7d043b9efabd5d249333168fa44e4fe6e54ba4c9541447b92983ceb
7
- data.tar.gz: 8dadc086c84a821d4a1b1824a25ea4861bdf0b6a36cfcf8c50a8d06e19d6853c35974dbefb03fedc9ccd7a3f57ff13a19d206c5eef152c1aa5ffbc1f789da1bc
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
- @telemetry = Telemetry.new(telemetry_flush_interval,
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
- @flush_timer = Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) }
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
- @flush_timer = Datadog::Statsd::Timer.new(flush_interval) { flush }
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
@@ -9,6 +9,7 @@ module Datadog
9
9
  @interval = interval
10
10
  @callback = callback
11
11
  @stop = true
12
+ @thread = nil
12
13
  end
13
14
 
14
15
  def start
@@ -4,6 +4,6 @@ require_relative 'connection'
4
4
 
5
5
  module Datadog
6
6
  class Statsd
7
- VERSION = '5.4.0'
7
+ VERSION = '5.5.0'
8
8
  end
9
9
  end
@@ -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.0
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-03-01 00:00:00.000000000 Z
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.4.0/CHANGELOG.md
48
- documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.4.0
49
- source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.4.0
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
- rubygems_version: 3.2.22
70
- signing_key:
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
+ ...