puma-plugin-statsd 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb512a32b788a2df3fc7f9f222e7dcb510fdbda09bb1bb278466978d2f5b511d
4
- data.tar.gz: 6274f07b78d32a6bddbc5d6d823114f6171df7fb3131186e35fbdd9416244ce1
3
+ metadata.gz: 1ac5651e242dcf306ed0c5964de2c7178a142e9555333cfd203e043dada926a6
4
+ data.tar.gz: 9cc7a3b70cdcda54a824ca4d9b65714c16f7b20834bb348182eb787820b5e5e1
5
5
  SHA512:
6
- metadata.gz: c568951db0c140e934d4cd40103c8b98160da02aeeda6b2549dd59a415ee2ee59ea171f6d818150fdbb66c99b88a912690c31f9bc3bc0715dc7478440136e76a
7
- data.tar.gz: 2af0724eb7a83bae47caed6c3009a5fa5ed2d0ab98b2c98be250c03636750bdf48788f69fe8bd04fb83a7656fb15174ab356edd0581eed072e780b4fa0855aa8
6
+ metadata.gz: 1222d6580444972583bec535348958301a8c5aa4860d08e87bb1e735fc09d9b2764a38b4c3b9aa355878b9080ca30ef80b413c55c0f8f4b97edf750515162a89
7
+ data.tar.gz: 07e8987c8ce8f8f3db573241f824c80224aec9ffa2f5b1e8bbd474105981d6529c0c1a4a870995622f62c9edad1181aaced6c3382b8746aebf9149f51d0842c9
data/CHANGELOG.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.0 2021-07-27
4
+
5
+ * Require puma 5 or better
6
+ * Split DD_TAGS environment variable by commas or spaces (PR #[31](https://github.com/yob/puma-plugin-statsd/pull/31))
7
+ * Gracefully handle unexpecte errors when submitting to statsd (like DNS resolution failures) (PR #[35](https://github.com/yob/puma-plugin-statsd/pull/35))
8
+
3
9
  ## 1.2.1 2021-01-11
4
10
 
5
11
  * Remove json from the gemspec
6
12
 
7
13
  ## 1.2.0 2021-01-07
8
14
 
9
- * New metrics: old_workers (PR #[21](https://github.com/yob/puma-plugin-statsd/pull/21)) and requsts_count (PR #[28](https://github.com/yob/puma-plugin-statsd/pull/28))
15
+ * New metrics: old_workers (PR #[21](https://github.com/yob/puma-plugin-statsd/pull/21)) and requests_count (PR #[28](https://github.com/yob/puma-plugin-statsd/pull/28))
10
16
  * Require json at runtime to be extra sure we don't load the wrong version before bundler has initialised the LOAD_PATH
11
17
 
12
18
  ## 1.1.0 2021-01-03
data/README.md CHANGED
@@ -9,6 +9,8 @@ that puma can provide:
9
9
  * puma.backlog
10
10
  * puma.pool_capacity
11
11
  * puma.max_threads
12
+ * puma.old_workers
13
+ * puma.requests_count
12
14
 
13
15
  [puma]: https://github.com/puma/puma
14
16
  [statsd]: https://github.com/etsy/statsd
@@ -108,9 +110,17 @@ https://github.com/yob/puma-plugin-statsd.
108
110
 
109
111
  ## Testing the data being sent to statsd
110
112
 
111
- Start a pretend statsd server that listens for UDP packets on port 8125:
113
+ Start a pretend statsd server that listens for UDP packets on port 8125.
112
114
 
113
- ruby devtools/statsd-to-stdout.rb
115
+ If you've installed the gem in your app:
116
+
117
+ # only need to install the binstub once
118
+ bundle binstubs puma-plugin-statsd
119
+ ./bin/statsd-to-stdout
120
+
121
+ If you are developing/testing this gem locally:
122
+
123
+ ./bin/statsd-to-stdout
114
124
 
115
125
  Start puma:
116
126
 
@@ -0,0 +1,15 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ RECV_BUFFER = 64*1024
5
+
6
+ require 'socket'
7
+ server = UDPSocket.new
8
+ host, port = "127.0.0.1", 8125
9
+ server.bind(host, port)
10
+
11
+ while true
12
+ text, sender = server.recvfrom(RECV_BUFFER)
13
+ remote_host = sender[3]
14
+ STDOUT.puts "#{remote_host}:" + text
15
+ end
@@ -112,18 +112,6 @@ Puma::Plugin.create do
112
112
  in_background(&method(:stats_loop))
113
113
  end
114
114
 
115
- if Puma.respond_to?(:stats_hash)
116
- def fetch_stats
117
- Puma.stats_hash
118
- end
119
- else
120
- def fetch_stats
121
- require "json"
122
- stats = Puma.stats
123
- JSON.parse(stats, symbolize_names: true)
124
- end
125
- end
126
-
127
115
  def environment_variable_tags
128
116
  # Tags are separated by spaces, and while they are normally a tag and
129
117
  # value separated by a ':', they can also just be tagged without any
@@ -147,7 +135,7 @@ Puma::Plugin.create do
147
135
  # https://docs.datadoghq.com/agent/docker/?tab=standard#global-options
148
136
  #
149
137
  if ENV.has_key?("DD_TAGS")
150
- ENV["DD_TAGS"].split(/\s+/).each do |t|
138
+ ENV["DD_TAGS"].split(/\s+|,/).each do |t|
151
139
  tags << t
152
140
  end
153
141
  end
@@ -171,7 +159,7 @@ Puma::Plugin.create do
171
159
  loop do
172
160
  @launcher.events.debug "statsd: notify statsd"
173
161
  begin
174
- stats = ::PumaStats.new(fetch_stats)
162
+ stats = ::PumaStats.new(Puma.stats_hash)
175
163
  @statsd.send(metric_name: prefixed_metric_name("puma.workers"), value: stats.workers, type: :gauge, tags: tags)
176
164
  @statsd.send(metric_name: prefixed_metric_name("puma.booted_workers"), value: stats.booted_workers, type: :gauge, tags: tags)
177
165
  @statsd.send(metric_name: prefixed_metric_name("puma.old_workers"), value: stats.old_workers, type: :gauge, tags: tags)
@@ -181,7 +169,7 @@ Puma::Plugin.create do
181
169
  @statsd.send(metric_name: prefixed_metric_name("puma.max_threads"), value: stats.max_threads, type: :gauge, tags: tags)
182
170
  @statsd.send(metric_name: prefixed_metric_name("puma.requests_count"), value: stats.requests_count, type: :gauge, tags: tags)
183
171
  rescue StandardError => e
184
- @launcher.events.error "! statsd: notify stats failed:\n #{e.to_s}\n #{e.backtrace.join("\n ")}"
172
+ @launcher.events.unknown_error e, nil, "! statsd: notify stats failed"
185
173
  ensure
186
174
  sleep 2
187
175
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-plugin-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.12'
19
+ version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '6'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '3.12'
29
+ version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6'
@@ -102,13 +102,15 @@ dependencies:
102
102
  version: '0'
103
103
  description:
104
104
  email: james@yob.id.au
105
- executables: []
105
+ executables:
106
+ - statsd-to-stdout
106
107
  extensions: []
107
108
  extra_rdoc_files: []
108
109
  files:
109
110
  - CHANGELOG.md
110
111
  - MIT-LICENSE
111
112
  - README.md
113
+ - bin/statsd-to-stdout
112
114
  - lib/puma/plugin/statsd.rb
113
115
  homepage: https://github.com/yob/puma-plugin-statsd
114
116
  licenses: