Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UDS socket configuration and improve error handling #391

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

pedro-stanaka
Copy link
Contributor

@pedro-stanaka pedro-stanaka commented Dec 18, 2024

✅ What

Problem

When using Unix Domain Sockets (UDS) with statsd-instrument, the max_packet_size configuration wasn't being properly passed through from the environment to the UDS connection. Additionally, error handling and debugging information for socket errors needed improvement.

What was done

  1. Fixed the Environment#default_sink_for_environment method to properly pass max_packet_size to both UDS and UDP connections
  2. Added better error handling and debugging information in the Sink class
  3. Added comprehensive tests for UDS socket configuration
  4. Fixed socket mock expectations in UDP sink tests

Notes

When using UDS with aggregation, be aware that the OS might impose its own limits on datagram sizes. The socket buffer size can be configured, but there might still be per-message size limits that can't be exceeded.

🤔 Why

The send buffer should match the max_packet size on the BatchedSink, otherwise messages will be dropped.

👩🔬 How to validate

Added tests for the behavior.

Checklist

  • I documented the changes in the CHANGELOG file.

#gsd:41649

we were not passing the correct value from the environment in the constructor

Signed-off-by: Pedro Tanaka <[email protected]>
@pedro-stanaka pedro-stanaka force-pushed the feat/too-big-package-uds branch 2 times, most recently from 38ce5c2 to 979c53c Compare December 18, 2024 17:47
Signed-off-by: Pedro Tanaka <[email protected]>

fixing ci

Signed-off-by: Pedro Tanaka <[email protected]>
@pedro-stanaka pedro-stanaka force-pushed the feat/too-big-package-uds branch from 979c53c to fea344d Compare December 18, 2024 17:50
@pedro-stanaka pedro-stanaka changed the title Fixing bug on UDS connection with packet size Fix UDS socket configuration and improve error handling Dec 18, 2024
Signed-off-by: Pedro Tanaka <[email protected]>
@pedro-stanaka pedro-stanaka marked this pull request as ready for review December 18, 2024 17:57
Copy link
Contributor

@ahayworth ahayworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some thought about validation of the value, but overall this looks okay to me.

lib/statsd/instrument/environment.rb Outdated Show resolved Hide resolved
lib/statsd/instrument/udp_connection.rb Outdated Show resolved Hide resolved
@pedro-stanaka pedro-stanaka force-pushed the feat/too-big-package-uds branch from 25c72b4 to 5ed58a3 Compare December 19, 2024 09:33
Signed-off-by: Pedro Tanaka <[email protected]>
@pedro-stanaka pedro-stanaka merged commit 4045921 into main Dec 19, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants