-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UDS socket configuration and improve error handling (#391)
* Fixing bug on UDS connection with packet size we were not passing the correct value from the environment in the constructor Signed-off-by: Pedro Tanaka <[email protected]> * Adding datadog gem benchmarks for cross comparison Signed-off-by: Pedro Tanaka <[email protected]> * appeasing rubocop Signed-off-by: Pedro Tanaka <[email protected]> fixing ci Signed-off-by: Pedro Tanaka <[email protected]> * add changelog, bump version Signed-off-by: Pedro Tanaka <[email protected]> * Introduce method for send buffer size and extract module Signed-off-by: Pedro Tanaka <[email protected]> * Improve handling of setting the send buffer vs the batched sink buffer Signed-off-by: Pedro Tanaka <[email protected]> * skipping UDS tests in jruby Signed-off-by: Pedro Tanaka <[email protected]> --------- Signed-off-by: Pedro Tanaka <[email protected]>
- Loading branch information
1 parent
fa7b330
commit 4045921
Showing
19 changed files
with
285 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: test lint update | ||
test: | ||
bundle exec rake test | ||
|
||
lint: | ||
bundle exec rake lint_fix | ||
|
||
update: | ||
bundle update | ||
|
||
check: update lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
module StatsD | ||
module Instrument | ||
module ConnectionBehavior | ||
def close | ||
@socket&.close | ||
rescue IOError, SystemCallError => e | ||
StatsD.logger.debug do | ||
"[#{self.class.name}] Error closing socket: #{e.class}: #{e.message}" | ||
end | ||
ensure | ||
@socket = nil | ||
end | ||
|
||
def send_buffer_size | ||
if socket | ||
send_buffer_size_from_socket(socket) | ||
else | ||
@max_packet_size | ||
end | ||
end | ||
|
||
def type | ||
raise NotImplementedError, "#{self.class} must implement #type" | ||
end | ||
|
||
private | ||
|
||
def send_buffer_size_from_socket(original_socket) | ||
original_socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).int | ||
end | ||
|
||
def setup_socket(original_socket) | ||
original_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, @max_packet_size.to_i) | ||
if send_buffer_size_from_socket(original_socket) < @max_packet_size | ||
StatsD.logger.warn do | ||
"[#{self.class.name}] Could not set socket send buffer size to #{@max_packet_size} " \ | ||
"allowed size by environment/OS is (#{send_buffer_size_from_socket(original_socket)})." | ||
end | ||
end | ||
original_socket | ||
rescue IOError => e | ||
StatsD.logger.debug do | ||
"[#{self.class.name}] Failed to create socket: #{e.class}: #{e.message}" | ||
end | ||
nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module StatsD | ||
module Instrument | ||
VERSION = "3.9.7" | ||
VERSION = "3.9.8" | ||
end | ||
end |
Oops, something went wrong.