statsd-instrument 3.9.7 → 3.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +3 -7
- data/CHANGELOG.md +9 -0
- data/Gemfile +5 -0
- data/Makefile +11 -0
- data/benchmark/local-udp-throughput +55 -0
- data/lib/statsd/instrument/client.rb +0 -1
- data/lib/statsd/instrument/connection_behavior.rb +51 -0
- data/lib/statsd/instrument/dogstatsd_datagram_builder.rb +0 -1
- data/lib/statsd/instrument/environment.rb +20 -7
- data/lib/statsd/instrument/expectation.rb +0 -1
- data/lib/statsd/instrument/sink.rb +5 -2
- data/lib/statsd/instrument/strict.rb +0 -1
- data/lib/statsd/instrument/udp_connection.rb +13 -9
- data/lib/statsd/instrument/uds_connection.rb +7 -10
- data/lib/statsd/instrument/version.rb +1 -1
- data/lib/statsd/instrument.rb +1 -0
- data/test/environment_test.rb +89 -0
- data/test/test_helper.rb +9 -0
- data/test/udp_sink_test.rb +6 -1
- data/test/uds_sink_test.rb +0 -4
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60ed39eafdc0c0c60e8b39cc40a525990f7a51c8bf0621bf657558f29e6767c4
|
4
|
+
data.tar.gz: 6d27813cbc21f7f5327cdc261d1dfd7c874d9c4f0c1fdfb17aee1ee63944ea9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cafa0a80f7c5d7374d8607698b03fc8eb9fe94cfd7b8a4c6accd1bb9ac4c66a83fea40215df8bcc87c4f729e4379956d2614970539375d13c2cd6d65840a5b9
|
7
|
+
data.tar.gz: 7e254ea3318a5fc3d79bcb648c5cc939dbbb1552f942c67c38f06d698f44659e790489b5a720cca815ca6998a59b317399a3a54350dca61defafc27ed2da15f6
|
data/.github/workflows/tests.yml
CHANGED
@@ -4,16 +4,12 @@ on: push
|
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
7
|
-
name: Ruby ${{ matrix.ruby }} on ubuntu-
|
8
|
-
runs-on: ubuntu-
|
7
|
+
name: Ruby ${{ matrix.ruby }} on ubuntu-22.04
|
8
|
+
runs-on: ubuntu-22.04
|
9
9
|
strategy:
|
10
10
|
fail-fast: false
|
11
11
|
matrix:
|
12
|
-
ruby: ['2.
|
13
|
-
# Windows on macOS builds started failing, so they are disabled for now
|
14
|
-
# platform: [windows-2019, macOS-10.14, ubuntu-18.04]
|
15
|
-
# exclude:
|
16
|
-
# ...
|
12
|
+
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', 'ruby-head', 'jruby-9.4.9.0', 'truffleruby-22.3.1']
|
17
13
|
|
18
14
|
steps:
|
19
15
|
- uses: actions/checkout@v4
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ section below.
|
|
6
6
|
|
7
7
|
## Unreleased changes
|
8
8
|
|
9
|
+
## Version 3.9.9
|
10
|
+
|
11
|
+
- [#392](https://github.com/Shopify/statsd-instrument/pull/392) - Prevent ENOBUFS errors when using UDP, by skipping setting socket buffer size.
|
12
|
+
|
13
|
+
## Version 3.9.8
|
14
|
+
|
15
|
+
- [#390](https://github.com/Shopify/statsd-instrument/pull/391) - Fixing bug in Environment when using UDS. The max packet size option was not being passed to the
|
16
|
+
UDS connection, causing messages that were too large to be dropped (specially sensitive when used together with BatchedSink).
|
17
|
+
|
9
18
|
## Version 3.9.7
|
10
19
|
|
11
20
|
- [#389](https://github.com/Shopify/statsd-instrument/pull/389) - Fixing bug with BatchedSink constructor when using UDS, the constructor was not properly passing the Sink to the BatchedSink.
|
data/Gemfile
CHANGED
@@ -19,4 +19,9 @@ platform :mri do
|
|
19
19
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2")
|
20
20
|
gem "vernier", require: false
|
21
21
|
end
|
22
|
+
|
23
|
+
# From Ruby >= 3.5, logger is not part of the stdlib anymore
|
24
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.5")
|
25
|
+
gem "logger"
|
26
|
+
end
|
22
27
|
end
|
data/Makefile
ADDED
@@ -10,6 +10,24 @@ require "datadog/statsd"
|
|
10
10
|
require "forwardable"
|
11
11
|
require "vernier"
|
12
12
|
|
13
|
+
module Datadog
|
14
|
+
class Statsd
|
15
|
+
class Telemetry
|
16
|
+
def flush
|
17
|
+
["bytes", "packets"].each do |kind|
|
18
|
+
["sent", "dropped", "dropped_queue", "dropped_writer"].each do |measure|
|
19
|
+
var = "#{kind}_#{measure}"
|
20
|
+
puts "#{var}: #{instance_variable_get("@#{var}".to_sym)}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
puts "-" * 10
|
24
|
+
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
13
31
|
class DatadogShim
|
14
32
|
extend Forwardable
|
15
33
|
|
@@ -222,3 +240,40 @@ benchmark_implementation(
|
|
222
240
|
if ENABLE_PROFILING
|
223
241
|
Vernier.stop_profile
|
224
242
|
end
|
243
|
+
|
244
|
+
if ENABLE_PROFILING
|
245
|
+
Vernier.start_profile(out: "tmp/benchmark_profile_datadog.json")
|
246
|
+
end
|
247
|
+
benchmark_implementation(
|
248
|
+
"Datadog client with UDP and delayed serialization",
|
249
|
+
{
|
250
|
+
buffer_max_payload_size: 4096,
|
251
|
+
delay_serialization: true,
|
252
|
+
telemetry_flush_interval: 1,
|
253
|
+
# The datadog implemtation will drop metrics if the queue is full
|
254
|
+
# to imitate the behavior of the implementation of this gem, we set
|
255
|
+
# the queue size to infinity to avoid dropping metrics.
|
256
|
+
sender_queue_size: Float::INFINITY,
|
257
|
+
},
|
258
|
+
true,
|
259
|
+
)
|
260
|
+
if ENABLE_PROFILING
|
261
|
+
Vernier.stop_profile
|
262
|
+
end
|
263
|
+
|
264
|
+
if ENABLE_PROFILING
|
265
|
+
Vernier.start_profile(out: "tmp/benchmark_profile_datadog.json")
|
266
|
+
end
|
267
|
+
benchmark_implementation(
|
268
|
+
"UDP - Datadog gem - using: delay_serialization, multi-threaded, allow dropping samples",
|
269
|
+
{
|
270
|
+
buffer_max_payload_size: 4096,
|
271
|
+
delay_serialization: true,
|
272
|
+
telemetry_flush_interval: 1,
|
273
|
+
sender_queue_size: 250_000,
|
274
|
+
},
|
275
|
+
true,
|
276
|
+
)
|
277
|
+
if ENABLE_PROFILING
|
278
|
+
Vernier.stop_profile
|
279
|
+
end
|
@@ -459,7 +459,6 @@ module StatsD
|
|
459
459
|
# @note Supported by the Datadog implementation only.
|
460
460
|
def event(title, text, timestamp: nil, hostname: nil, aggregation_key: nil, priority: nil,
|
461
461
|
source_type_name: nil, alert_type: nil, tags: nil, no_prefix: false)
|
462
|
-
|
463
462
|
emit(datagram_builder(no_prefix: no_prefix)._e(
|
464
463
|
title,
|
465
464
|
text,
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StatsD
|
4
|
+
module Instrument
|
5
|
+
module ConnectionBehavior
|
6
|
+
def close
|
7
|
+
@socket&.close
|
8
|
+
rescue IOError, SystemCallError => e
|
9
|
+
StatsD.logger.debug do
|
10
|
+
"[#{self.class.name}] Error closing socket: #{e.class}: #{e.message}"
|
11
|
+
end
|
12
|
+
ensure
|
13
|
+
@socket = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def send_buffer_size
|
17
|
+
if socket
|
18
|
+
send_buffer_size_from_socket(socket)
|
19
|
+
else
|
20
|
+
@max_packet_size
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def type
|
25
|
+
raise NotImplementedError, "#{self.class} must implement #type"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def send_buffer_size_from_socket(original_socket)
|
31
|
+
original_socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).int
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_socket(original_socket)
|
35
|
+
original_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, @max_packet_size.to_i)
|
36
|
+
if send_buffer_size_from_socket(original_socket) < @max_packet_size
|
37
|
+
StatsD.logger.warn do
|
38
|
+
"[#{self.class.name}] Could not set socket send buffer size to #{@max_packet_size} " \
|
39
|
+
"allowed size by environment/OS is (#{send_buffer_size_from_socket(original_socket)})."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
original_socket
|
43
|
+
rescue IOError => e
|
44
|
+
StatsD.logger.debug do
|
45
|
+
"[#{self.class.name}] Failed to setup socket: #{e.class}: #{e.message}"
|
46
|
+
end
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -33,7 +33,6 @@ module StatsD
|
|
33
33
|
# @see https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/#events
|
34
34
|
def _e(title, text, timestamp: nil, hostname: nil, aggregation_key: nil, priority: nil,
|
35
35
|
source_type_name: nil, alert_type: nil, tags: nil)
|
36
|
-
|
37
36
|
escaped_title = "#{@prefix}#{title}".gsub("\n", '\n')
|
38
37
|
escaped_text = text.gsub("\n", '\n')
|
39
38
|
|
@@ -104,10 +104,10 @@ module StatsD
|
|
104
104
|
|
105
105
|
def statsd_max_packet_size
|
106
106
|
if statsd_uds_send?
|
107
|
-
|
107
|
+
Integer(env.fetch("STATSD_MAX_PACKET_SIZE", StatsD::Instrument::UdsConnection::DEFAULT_MAX_PACKET_SIZE))
|
108
|
+
else
|
109
|
+
Integer(env.fetch("STATSD_MAX_PACKET_SIZE", StatsD::Instrument::UdpConnection::DEFAULT_MAX_PACKET_SIZE))
|
108
110
|
end
|
109
|
-
|
110
|
-
Float(env.fetch("STATSD_MAX_PACKET_SIZE", StatsD::Instrument::UdpConnection::DEFAULT_MAX_PACKET_SIZE))
|
111
111
|
end
|
112
112
|
|
113
113
|
def statsd_batch_statistics_interval
|
@@ -140,19 +140,32 @@ module StatsD
|
|
140
140
|
case environment
|
141
141
|
when "production", "staging"
|
142
142
|
connection = if statsd_uds_send?
|
143
|
-
StatsD::Instrument::UdsConnection.new(
|
143
|
+
StatsD::Instrument::UdsConnection.new(
|
144
|
+
statsd_socket_path,
|
145
|
+
max_packet_size: statsd_max_packet_size,
|
146
|
+
)
|
144
147
|
else
|
145
148
|
host, port = statsd_addr.split(":")
|
146
|
-
StatsD::Instrument::UdpConnection.new(
|
149
|
+
StatsD::Instrument::UdpConnection.new(
|
150
|
+
host,
|
151
|
+
port.to_i,
|
152
|
+
max_packet_size: statsd_max_packet_size,
|
153
|
+
)
|
147
154
|
end
|
148
155
|
|
149
156
|
sink = StatsD::Instrument::Sink.new(connection)
|
150
157
|
if statsd_batching?
|
151
|
-
|
158
|
+
current_send_buffer_size = connection.send_buffer_size
|
159
|
+
if current_send_buffer_size < statsd_max_packet_size
|
160
|
+
StatsD.logger.warn do
|
161
|
+
"[StatsD::Instrument::Environment] Send buffer size #{current_send_buffer_size} differs from " \
|
162
|
+
"max packet size #{statsd_max_packet_size}. Using send buffer size as max packet size."
|
163
|
+
end
|
164
|
+
end
|
152
165
|
return StatsD::Instrument::BatchedSink.new(
|
153
166
|
sink,
|
154
167
|
buffer_capacity: statsd_buffer_capacity,
|
155
|
-
max_packet_size: statsd_max_packet_size,
|
168
|
+
max_packet_size: [current_send_buffer_size, statsd_max_packet_size].min,
|
156
169
|
statistics_interval: statsd_batch_statistics_interval,
|
157
170
|
)
|
158
171
|
end
|
@@ -36,7 +36,6 @@ module StatsD
|
|
36
36
|
|
37
37
|
def initialize(client: nil, type:, name:, value: nil,
|
38
38
|
sample_rate: nil, tags: nil, no_prefix: false, times: 1)
|
39
|
-
|
40
39
|
@type = type
|
41
40
|
@name = no_prefix ? name : StatsD::Instrument::Helpers.prefix_metric(name, client: client)
|
42
41
|
@value = normalized_value_for_type(type, value) if value
|
@@ -40,12 +40,15 @@ module StatsD
|
|
40
40
|
connection.send_datagram(datagram)
|
41
41
|
rescue SocketError, IOError, SystemCallError => error
|
42
42
|
StatsD.logger.debug do
|
43
|
-
"[#{self.class.name}]
|
43
|
+
"[#{self.class.name}] [#{connection.class.name}] " \
|
44
|
+
"Resetting connection because of #{error.class}: #{error.message}"
|
44
45
|
end
|
45
46
|
invalidate_connection
|
46
47
|
if retried
|
47
48
|
StatsD.logger.warn do
|
48
|
-
"[#{self.class.name}]
|
49
|
+
"[#{self.class.name}] [#{connection.class.name}] " \
|
50
|
+
"Events were dropped (after retrying) because of #{error.class}: #{error.message}. " \
|
51
|
+
"Message size: #{datagram.bytesize} bytes."
|
49
52
|
end
|
50
53
|
else
|
51
54
|
retried = true
|
@@ -3,35 +3,39 @@
|
|
3
3
|
module StatsD
|
4
4
|
module Instrument
|
5
5
|
class UdpConnection
|
6
|
+
include ConnectionBehavior
|
7
|
+
|
6
8
|
DEFAULT_MAX_PACKET_SIZE = 1_472
|
7
9
|
|
8
10
|
attr_reader :host, :port
|
9
11
|
|
10
|
-
def initialize(host, port)
|
12
|
+
def initialize(host, port, max_packet_size: DEFAULT_MAX_PACKET_SIZE)
|
11
13
|
@host = host
|
12
14
|
@port = port
|
15
|
+
@max_packet_size = max_packet_size
|
13
16
|
end
|
14
17
|
|
15
18
|
def send_datagram(message)
|
16
19
|
socket.send(message, 0)
|
17
20
|
end
|
18
21
|
|
19
|
-
def close
|
20
|
-
@socket&.close
|
21
|
-
@socket = nil
|
22
|
-
end
|
23
|
-
|
24
22
|
def type
|
25
23
|
:udp
|
26
24
|
end
|
27
25
|
|
28
26
|
private
|
29
27
|
|
28
|
+
def setup_socket(original_socket)
|
29
|
+
original_socket
|
30
|
+
end
|
31
|
+
|
30
32
|
def socket
|
31
33
|
@socket ||= begin
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
family = Addrinfo.udp(host, port).afamily
|
35
|
+
udp_socket = UDPSocket.new(family)
|
36
|
+
setup_socket(udp_socket)&.tap do |s|
|
37
|
+
s.connect(host, port)
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module StatsD
|
4
4
|
module Instrument
|
5
5
|
class UdsConnection
|
6
|
+
include ConnectionBehavior
|
7
|
+
|
6
8
|
DEFAULT_MAX_PACKET_SIZE = 8_192
|
7
9
|
|
8
10
|
def initialize(socket_path, max_packet_size: DEFAULT_MAX_PACKET_SIZE)
|
@@ -17,12 +19,7 @@ module StatsD
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def send_datagram(message)
|
20
|
-
socket
|
21
|
-
end
|
22
|
-
|
23
|
-
def close
|
24
|
-
@socket&.close
|
25
|
-
@socket = nil
|
22
|
+
socket&.sendmsg(message, 0)
|
26
23
|
end
|
27
24
|
|
28
25
|
def host
|
@@ -41,10 +38,10 @@ module StatsD
|
|
41
38
|
|
42
39
|
def socket
|
43
40
|
@socket ||= begin
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
unix_socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
|
42
|
+
setup_socket(unix_socket)&.tap do |s|
|
43
|
+
s.connect(Socket.pack_sockaddr_un(@socket_path))
|
44
|
+
end
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|
data/lib/statsd/instrument.rb
CHANGED
@@ -401,6 +401,7 @@ require "statsd/instrument/environment"
|
|
401
401
|
require "statsd/instrument/helpers"
|
402
402
|
require "statsd/instrument/assertions"
|
403
403
|
require "statsd/instrument/expectation"
|
404
|
+
require "statsd/instrument/connection_behavior"
|
404
405
|
require "statsd/instrument/uds_connection"
|
405
406
|
require "statsd/instrument/udp_connection"
|
406
407
|
require "statsd/instrument/sink"
|
data/test/environment_test.rb
CHANGED
@@ -76,4 +76,93 @@ class EnvironmentTest < Minitest::Test
|
|
76
76
|
)
|
77
77
|
assert_kind_of(StatsD::Instrument::Sink, env.client.sink)
|
78
78
|
end
|
79
|
+
|
80
|
+
def test_client_from_env_uses_uds_sink_with_correct_packet_size_in_production
|
81
|
+
skip_on_jruby("JRuby does not support UNIX domain sockets")
|
82
|
+
socket_path = "/tmp/statsd-test-#{Process.pid}.sock"
|
83
|
+
|
84
|
+
# Create a UDS server socket
|
85
|
+
server = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
|
86
|
+
server.bind(Socket.pack_sockaddr_un(socket_path))
|
87
|
+
|
88
|
+
env = StatsD::Instrument::Environment.new(
|
89
|
+
"STATSD_ENV" => "production",
|
90
|
+
"STATSD_SOCKET_PATH" => socket_path,
|
91
|
+
"STATSD_MAX_PACKET_SIZE" => "65507",
|
92
|
+
"STATSD_USE_NEW_CLIENT" => "1",
|
93
|
+
)
|
94
|
+
|
95
|
+
begin
|
96
|
+
client = env.client
|
97
|
+
sink = client.sink
|
98
|
+
connection = sink.connection
|
99
|
+
|
100
|
+
assert_kind_of(StatsD::Instrument::UdsConnection, connection)
|
101
|
+
assert_equal(65507, connection.instance_variable_get(:@max_packet_size))
|
102
|
+
ensure
|
103
|
+
server.close
|
104
|
+
File.unlink(socket_path) if File.exist?(socket_path)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_client_from_env_uses_default_packet_size_for_uds_when_not_specified
|
109
|
+
skip_on_jruby("JRuby does not support UNIX domain sockets")
|
110
|
+
socket_path = "/tmp/statsd-test-#{Process.pid}-default.sock"
|
111
|
+
|
112
|
+
# Create a UDS server socket
|
113
|
+
server = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
|
114
|
+
server.bind(Socket.pack_sockaddr_un(socket_path))
|
115
|
+
|
116
|
+
env = StatsD::Instrument::Environment.new(
|
117
|
+
"STATSD_ENV" => "production",
|
118
|
+
"STATSD_SOCKET_PATH" => socket_path,
|
119
|
+
"STATSD_USE_NEW_CLIENT" => "1",
|
120
|
+
)
|
121
|
+
|
122
|
+
begin
|
123
|
+
client = env.client
|
124
|
+
sink = client.sink
|
125
|
+
connection = sink.connection
|
126
|
+
|
127
|
+
assert_kind_of(StatsD::Instrument::UdsConnection, connection)
|
128
|
+
assert_equal(
|
129
|
+
StatsD::Instrument::UdsConnection::DEFAULT_MAX_PACKET_SIZE,
|
130
|
+
connection.instance_variable_get(:@max_packet_size),
|
131
|
+
)
|
132
|
+
ensure
|
133
|
+
server.close
|
134
|
+
File.unlink(socket_path) if File.exist?(socket_path)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_client_from_env_uses_batched_uds_sink_with_correct_packet_size
|
139
|
+
skip_on_jruby("JRuby does not support UNIX domain sockets")
|
140
|
+
socket_path = "/tmp/statsd-test-#{Process.pid}-batched.sock"
|
141
|
+
|
142
|
+
# Create a UDS server socket
|
143
|
+
server = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
|
144
|
+
server.bind(Socket.pack_sockaddr_un(socket_path))
|
145
|
+
|
146
|
+
env = StatsD::Instrument::Environment.new(
|
147
|
+
"STATSD_ENV" => "production",
|
148
|
+
"STATSD_SOCKET_PATH" => socket_path,
|
149
|
+
"STATSD_MAX_PACKET_SIZE" => "65507",
|
150
|
+
"STATSD_BUFFER_CAPACITY" => "1000",
|
151
|
+
"STATSD_USE_NEW_CLIENT" => "1",
|
152
|
+
)
|
153
|
+
|
154
|
+
begin
|
155
|
+
client = env.client
|
156
|
+
sink = client.sink
|
157
|
+
assert_kind_of(StatsD::Instrument::BatchedSink, sink)
|
158
|
+
|
159
|
+
underlying_sink = sink.instance_variable_get(:@sink)
|
160
|
+
connection = underlying_sink.connection
|
161
|
+
assert_kind_of(StatsD::Instrument::UdsConnection, connection)
|
162
|
+
assert_equal(65507, connection.instance_variable_get(:@max_packet_size))
|
163
|
+
ensure
|
164
|
+
server.close
|
165
|
+
File.unlink(socket_path) if File.exist?(socket_path)
|
166
|
+
end
|
167
|
+
end
|
79
168
|
end
|
data/test/test_helper.rb
CHANGED
@@ -30,6 +30,15 @@ module StatsD
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
# Add helper methods available to all tests
|
34
|
+
module Minitest
|
35
|
+
class Test
|
36
|
+
def skip_on_jruby(message = "Test skipped on JRuby")
|
37
|
+
skip(message) if RUBY_ENGINE == "jruby"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
33
42
|
StatsD.logger = Logger.new(File::NULL)
|
34
43
|
|
35
44
|
Thread.abort_on_exception = true
|
data/test/udp_sink_test.rb
CHANGED
@@ -149,9 +149,13 @@ class UDPSinkTest < Minitest::Test
|
|
149
149
|
UDPSocket.stubs(:new).returns(socket = mock("socket"))
|
150
150
|
|
151
151
|
seq = sequence("connect_fail_connect_succeed")
|
152
|
+
|
153
|
+
# First attempt
|
152
154
|
socket.expects(:connect).with("localhost", 8125).in_sequence(seq)
|
153
155
|
socket.expects(:send).raises(Errno::EDESTADDRREQ).in_sequence(seq)
|
154
156
|
socket.expects(:close).in_sequence(seq)
|
157
|
+
|
158
|
+
# Second attempt after error
|
155
159
|
socket.expects(:connect).with("localhost", 8125).in_sequence(seq)
|
156
160
|
socket.expects(:send).twice.returns(1).in_sequence(seq)
|
157
161
|
socket.expects(:close).in_sequence(seq)
|
@@ -161,7 +165,8 @@ class UDPSinkTest < Minitest::Test
|
|
161
165
|
udp_sink << "bar:1|c"
|
162
166
|
|
163
167
|
assert_equal(
|
164
|
-
"[#{@sink_class}]
|
168
|
+
"[#{@sink_class}] [#{@sink_class.for_addr("localhost:8125").connection.class}] " \
|
169
|
+
"Resetting connection because of " \
|
165
170
|
"Errno::EDESTADDRREQ: Destination address required\n",
|
166
171
|
logs.string,
|
167
172
|
)
|
data/test/uds_sink_test.rb
CHANGED
@@ -35,10 +35,6 @@ module UdsTestHelper
|
|
35
35
|
@sink ||= build_sink(@socket_path)
|
36
36
|
end
|
37
37
|
|
38
|
-
def skip_on_jruby(message = "JRuby does not support UNIX domain sockets")
|
39
|
-
skip(message) if RUBY_PLATFORM == "java"
|
40
|
-
end
|
41
|
-
|
42
38
|
def read_datagrams(count, timeout: ENV["CI"] ? 5 : 1)
|
43
39
|
datagrams = []
|
44
40
|
count.times do
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsd-instrument
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.
|
4
|
+
version: 3.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Storimer
|
8
8
|
- Tobias Lutke
|
9
9
|
- Willem van Bergen
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2025-01-14 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
|
16
15
|
StatsD instrumentation into your code.
|
@@ -34,6 +33,7 @@ files:
|
|
34
33
|
- CONTRIBUTING.md
|
35
34
|
- Gemfile
|
36
35
|
- LICENSE
|
36
|
+
- Makefile
|
37
37
|
- README.md
|
38
38
|
- Rakefile
|
39
39
|
- benchmark/README.md
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/statsd/instrument/batched_sink.rb
|
50
50
|
- lib/statsd/instrument/capture_sink.rb
|
51
51
|
- lib/statsd/instrument/client.rb
|
52
|
+
- lib/statsd/instrument/connection_behavior.rb
|
52
53
|
- lib/statsd/instrument/datagram.rb
|
53
54
|
- lib/statsd/instrument/datagram_builder.rb
|
54
55
|
- lib/statsd/instrument/dogstatsd_datagram.rb
|
@@ -115,7 +116,6 @@ licenses:
|
|
115
116
|
- MIT
|
116
117
|
metadata:
|
117
118
|
allowed_push_host: https://rubygems.org
|
118
|
-
post_install_message:
|
119
119
|
rdoc_options: []
|
120
120
|
require_paths:
|
121
121
|
- lib
|
@@ -130,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
-
signing_key:
|
133
|
+
rubygems_version: 3.6.2
|
135
134
|
specification_version: 4
|
136
135
|
summary: A StatsD client for Ruby apps
|
137
136
|
test_files:
|