puma-plugin-statsd 2.1.0 → 2.3.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: 4794cf011c7fa906180ab8dfa2b0d89a0a1c942cbfbce0725d72facb68804a32
4
- data.tar.gz: 65b939ecf211d9fb4749d67e03b273524ad61794758f5f6a89a6a6023e66c870
3
+ metadata.gz: 1ae9c9480d1241bd90b7a2b0deb90b48e5effd7c48e85131db1c76b67a58934d
4
+ data.tar.gz: 1037c175245a0f94d4c73e8531cf8de04e619840516fc00a910353933bf44172
5
5
  SHA512:
6
- metadata.gz: 8de8010e2f5716873518f03ebf3534ae2f4059423d825c2cd1da728fa8cf4511b3220abe661d8ab1d12f945f954934d4e6361b936ced61310162fa33440b014e
7
- data.tar.gz: dbb9a2486a4b1f01a69de349286c280897ab243fbab47507c695b6eaeda38ca91e4a9780d8d874b48a06411261c1b6ebdc1c71343048ac06c2ee842114e68428
6
+ metadata.gz: 2f69cf9f81b61a53aeb195b8f3706232e2793a0bc365c654b2a8338573c10e6ff0ca7e6ecf39651d128c5929111ef350bd3284c5f22d1d15bf5560d807b90e15
7
+ data.tar.gz: 9c5b0671b4c9e62c790b1e534e11990b93542f56e8da9b42ab050bc007c631ac961b2d66d99d05d7ab3a8b7bd2a1113200ec439306e1f937ff8c97c2c3f342e9
data/CHANGELOG.md CHANGED
@@ -1,14 +1,22 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.3.0 2022-11-26
4
+
5
+ * Support the origin detection over UDP from Datadog via DD_ENTITY_ID env var
6
+
7
+ ## 2.2.0 2022-07-31
8
+
9
+ * Support communicating with the Datadog agent via a UNIX socket (set STATSD_SOCKET_PATH env var) (PR #[38](https://github.com/yob/puma-plugin-statsd/pull/38))
10
+
3
11
  ## 2.1.0 2021-12-04
4
12
 
5
- * Adds support for Datadog unified service tagging (env, service, version) (PR #[31](https://github.com/yob/puma-plugin-statsd/pull/37))
13
+ * Adds support for Datadog unified service tagging (env, service, version) (PR #[37](https://github.com/yob/puma-plugin-statsd/pull/37))
6
14
 
7
15
  ## 2.0.0 2021-07-27
8
16
 
9
17
  * Require puma 5 or better
10
18
  * Split DD_TAGS environment variable by commas or spaces (PR #[31](https://github.com/yob/puma-plugin-statsd/pull/31))
11
- * Gracefully handle unexpecte errors when submitting to statsd (like DNS resolution failures) (PR #[35](https://github.com/yob/puma-plugin-statsd/pull/35))
19
+ * Gracefully handle unexpected errors when submitting to statsd (like DNS resolution failures) (PR #[35](https://github.com/yob/puma-plugin-statsd/pull/35))
12
20
 
13
21
  ## 1.2.1 2021-01-11
14
22
 
@@ -13,14 +13,21 @@ class StatsdConnector
13
13
  def initialize
14
14
  @host = ENV.fetch(ENV_NAME, "127.0.0.1")
15
15
  @port = ENV.fetch("STATSD_PORT", 8125)
16
+ @socket_path = ENV.fetch("STATSD_SOCKET_PATH", nil)
16
17
  end
17
18
 
18
19
  def send(metric_name:, value:, type:, tags: nil)
19
20
  data = "#{metric_name}:#{value}|#{STATSD_TYPES.fetch(type)}"
20
21
  data = "#{data}|##{tags}" unless tags.nil?
21
22
 
22
- socket = UDPSocket.new
23
- socket.send(data, 0, host, port)
23
+ if @socket_path
24
+ socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
25
+ socket.connect(Socket.pack_sockaddr_un(@socket_path))
26
+ socket.sendmsg_nonblock(data)
27
+ else
28
+ socket = UDPSocket.new
29
+ socket.send(data, 0, host, port)
30
+ end
24
31
  ensure
25
32
  socket.close
26
33
  end
@@ -156,6 +163,14 @@ Puma::Plugin.create do
156
163
  tags << "version:#{ENV["DD_VERSION"]}"
157
164
  end
158
165
 
166
+ # Support the origin detection over UDP from Datadog, it allows DogStatsD
167
+ # to detect where the container metrics come from, and tag metrics automatically.
168
+ #
169
+ # https://docs.datadoghq.com/developers/dogstatsd/?tab=kubernetes#origin-detection-over-udp
170
+ if ENV.has_key?("DD_ENTITY_ID")
171
+ tags << "dd.internal.entity_id:#{ENV["DD_ENTITY_ID"]}"
172
+ end
173
+
159
174
  # Return nil if we have no environment variable tags. This way we don't
160
175
  # send an unnecessary '|' on the end of each stat
161
176
  return nil if tags.empty?
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: 2.1.0
4
+ version: 2.3.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-12-04 00:00:00.000000000 Z
11
+ date: 2022-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.2.3
134
+ rubygems_version: 3.3.7
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Send puma metrics to statsd via a background thread