dogstatsd-ruby 5.3.1 → 5.3.2

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: 539ec3d4e02bd8784df4d032b0f8e96ebb2a582b510ff5e27c6e7cfff4515926
4
- data.tar.gz: d8ecf4c6724e491aaea6d738cc255891b55119987b1ca5665087d506552135ee
3
+ metadata.gz: cfde2027b6fb73eee85ed0c612db51df707c2b01bec2266a3f2049acc34990f1
4
+ data.tar.gz: 5b1bb3263af1cbdde2bb84cf4d92f2e84ad7e0a0b3eaa5ad67f048750c062c46
5
5
  SHA512:
6
- metadata.gz: d615efd205f7858c55b9864e1d001d607dcb39a47a26c87f5e27402b25834cf750fb3904d10d667c63a437587d38ba315d7a3c609b7709bc28a8bc8138d30eef
7
- data.tar.gz: 254bf33695141f521d55d5f5b9c4d6b3abf2408b6b231263949094cbc2c9f531bf3ff2aea92ae0f11d505bbb8d25a789a2c0da76d9a065b713f9dc9b5b9d836d
6
+ metadata.gz: 2b563e322f2eaff18eeb07f786d6277290c032e94859d89d856a7bc2512a278424ab5ec9f94f8bf477a222e9ef00075ad2e0293b29dbb0021a5b6551f836b3c9
7
+ data.tar.gz: 787b04cc62a139289784a9b1992a152ca74fafa3d97afa68944dea95121ff6d3af80164b551b5430d50b263f0d0c8f702d22c1450faaaebdbc4bc69f09c331fe
@@ -4,6 +4,6 @@ require_relative 'connection'
4
4
 
5
5
  module Datadog
6
6
  class Statsd
7
- VERSION = '5.3.1'
7
+ VERSION = '5.3.2'
8
8
  end
9
9
  end
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.3.1
4
+ version: 5.3.2
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: 2021-10-21 00:00:00.000000000 Z
12
+ date: 2021-11-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Ruby DogStatsd client
15
15
  email: code@datadoghq.com
@@ -34,7 +34,6 @@ files:
34
34
  - lib/datadog/statsd/serialization/tag_serializer.rb
35
35
  - lib/datadog/statsd/single_thread_sender.rb
36
36
  - lib/datadog/statsd/telemetry.rb
37
- - lib/datadog/statsd/threaded_sender.rb
38
37
  - lib/datadog/statsd/udp_connection.rb
39
38
  - lib/datadog/statsd/uds_connection.rb
40
39
  - lib/datadog/statsd/version.rb
@@ -43,10 +42,14 @@ licenses:
43
42
  - MIT
44
43
  metadata:
45
44
  bug_tracker_uri: https://github.com/DataDog/dogstatsd-ruby/issues
46
- changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.3.1/CHANGELOG.md
47
- documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.3.1
48
- source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.3.1
49
- post_install_message:
45
+ changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.3.2/CHANGELOG.md
46
+ documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.3.2
47
+ source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.3.2
48
+ post_install_message: |2+
49
+
50
+ If you are upgrading from v4.x of the dogstatsd-ruby library, note the major change to the threading model:
51
+ https://github.com/DataDog/dogstatsd-ruby#migrating-from-v4x-to-v5x
52
+
50
53
  rdoc_options: []
51
54
  require_paths:
52
55
  - lib
@@ -61,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
64
  - !ruby/object:Gem::Version
62
65
  version: '0'
63
66
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.7.10
66
- signing_key:
67
+ rubygems_version: 3.2.22
68
+ signing_key:
67
69
  specification_version: 4
68
70
  summary: A Ruby DogStatsd client
69
71
  test_files: []
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- class FlushQueue < Queue
5
- end
6
- class CloseQueue < Queue
7
- end
8
- class Statsd
9
- # Sender is using a background thread to flush and pack messages
10
- # in a `MessageBuffer`.
11
- # The communication with this thread is done using a `Queue`.
12
- # If the thread is dead, it is starting a new one to avoid having a blocked
13
- # Sender with no background thread to communicate with (most of the time,
14
- # having a dead background thread means that a fork just happened and that we
15
- # are running in the child process).
16
- class Sender
17
- CLOSEABLE_QUEUES = Queue.instance_methods.include?(:close)
18
-
19
- def initialize(message_buffer, logger: nil)
20
- @message_buffer = message_buffer
21
- @logger = logger
22
-
23
- # communication and synchronization with the background thread
24
- # @mux is also used to not having multiple threads fighting for
25
- # closing the Sender or creating a new background thread
26
- @channel = Queue.new
27
- @mux = Mutex.new
28
-
29
- @is_closed = false
30
-
31
- # start background thread immediately
32
- @sender_thread = Thread.new(&method(:send_loop))
33
- end
34
-
35
- def flush(sync: false)
36
- @mux.synchronize {
37
- # we don't want to send a flush action to the bg thread if:
38
- # - there is no bg thread running
39
- # - the sender has been closed
40
- return if !sender_thread.alive? || @is_closed
41
-
42
- if sync
43
- # blocking flush
44
- blocking_queue = FlushQueue.new
45
- channel << blocking_queue
46
- blocking_queue.pop # wait for the bg thread to finish its work
47
- blocking_queue.close if CLOSEABLE_QUEUES
48
- else
49
- # asynchronous flush
50
- channel << :flush
51
- end
52
- }
53
- end
54
-
55
- def add(message)
56
- return if @is_closed # don't send a message to the bg thread if the sender has been closed
57
-
58
- # the bg thread is not running anymore, this is happening if the main process has forked and
59
- # we are running in the child, we will spawn a bg thread and reset buffers (containing parents' messages)
60
- if !sender_thread.alive?
61
- @mux.synchronize {
62
- return if @is_closed
63
- # test if a call from another thread has already re-created
64
- # the background thread before this one acquired the lock
65
- break if sender_thread.alive?
66
-
67
- # re-create the channel of communication since we will spawn a new bg thread
68
- channel.close if CLOSEABLE_QUEUES
69
- @channel = Queue.new
70
- message_buffer.reset # don't use messages appended by another fork
71
- @sender_thread = Thread.new(&method(:send_loop))
72
- }
73
- end
74
-
75
- channel << message
76
- end
77
-
78
- # Compatibility with `Sender`
79
- def start()
80
- end
81
-
82
- def stop()
83
- return if @is_closed
84
- # use this lock to both: not having another thread stopping this instance nor
85
- # having a #add call creating a new thread
86
- @mux.synchronize {
87
- @is_closed = true
88
- if sender_thread.alive? # no reasons to stop the bg thread is none is running already
89
- blocking_queue = CloseQueue.new
90
- channel << blocking_queue
91
- blocking_queue.pop # wait for the bg thread to finish its work
92
- blocking_queue.close if CLOSEABLE_QUEUES
93
- sender_thread.join(3) # wait for completion, timeout after 3 seconds
94
- # TODO(remy): should I close `channel` here?
95
- end
96
- }
97
- end
98
-
99
- private
100
-
101
- attr_reader :message_buffer
102
- attr_reader :channel
103
- attr_reader :mux
104
- attr_reader :sender_thread
105
-
106
- def send_loop
107
- until (message = channel.pop).nil? && (CLOSEABLE_QUEUES && channel.closed?)
108
- # skip if message is nil, e.g. when the channel is empty and closed
109
- next unless message
110
-
111
- case message
112
- # if a FlushQueue is received, the background thread has to flush the message
113
- # buffer and to send an :unblock to let the caller know that it has finished
114
- when FlushQueue
115
- message_buffer.flush
116
- message << :unblock
117
- # if a :flush is received, the background thread has to flush asynchronously
118
- when :flush
119
- message_buffer.flush
120
- # if a CloseQueue is received, the background thread has to do a last flush
121
- # and to send an :unblock to let the caller know that it has finished
122
- when CloseQueue
123
- message << :unblock
124
- return
125
- else
126
- message_buffer.add(message)
127
- end
128
- end
129
- end
130
- end
131
- end
132
- end