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

Allow using Unix Domain Socket instead of UDP #472

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

rubenruizdegauna
Copy link
Contributor

Allow using Unix Domain Sockets instead of UDP for the server.
If the metrics-addr is not empty and not [host]:port combination it will be considered a Unix Socket path and it will create and listen in that socket instead of UDP.

@atlassian-cla-bot
Copy link

atlassian-cla-bot bot commented Mar 18, 2022

Hooray! All contributors have signed the CLA.

Copy link
Member

@aelse aelse left a comment

Choose a reason for hiding this comment

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

Thanks @rubenruizdegauna . I would prefer not to make this the default behaviour applied to a metrics-addr string. We could use either a uri form unix:///path/to/socket (as some other systems do) or an abs path /path/to/socket to indicate unix domain sockets. I'd be happy with the abs path and we can identify a unix socket by looking for prefix '/'.

README.md Outdated
@@ -47,6 +47,10 @@ to run `gostatsd` with a graphite backend and a grafana dashboard.
While not generally tested on Windows, it should work. Maximum throughput is likely to be better on
a linux system, however.

The server listens for UDP packets by default. Unix Domain Sockets (UDS) can be used specifying a file path instead
Copy link
Member

Choose a reason for hiding this comment

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

Rather than abbreviating to UDS (which afaik is not generally used) we could use a shorthand of 'unix sockets' or 'IPC sockets'. I don't want to nitpick but we should use the accepted terminology - if i'm wrong and UDS is a commonly used acronym for this then that's fine.

Copy link
Contributor Author

@rubenruizdegauna rubenruizdegauna Mar 21, 2022

Choose a reason for hiding this comment

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

👍 I've used unix sockets and rephrased it a bit in b17ebf5

README.md Outdated
@@ -47,6 +47,10 @@ to run `gostatsd` with a graphite backend and a grafana dashboard.
While not generally tested on Windows, it should work. Maximum throughput is likely to be better on
a linux system, however.

The server listens for UDP packets by default. Unix Domain Sockets (UDS) can be used specifying a file path instead
of `address:port` with the `metrics-addr` configuration option. This only works on linux and will ignore `conn-per-reader`
configuration option.
Copy link
Member

Choose a reason for hiding this comment

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

Somewhere the docs should mention the socket mode is SOCK_DGRAM not SOCK_STREAM

Copy link
Contributor Author

@rubenruizdegauna rubenruizdegauna Mar 21, 2022

Choose a reason for hiding this comment

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

I've added it to this paragraph in b17ebf5. I wasn't sure if it was too much info about the socket in this section and I thought about adding another section just for this. Let me know what do you think and I can quickly change it.

Copy link
Member

@aelse aelse left a comment

Choose a reason for hiding this comment

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

Please change this to treat an absolute path as a socket and avoid the UDS acronym (unless that genuinely is the widely recognised acronym)

@@ -2,12 +2,15 @@ package statsd

import (
"context"
"net"
"os"
"runtime"
"sync"
"testing"
"time"

"github.com/magiconair/properties/assert"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't realize we had other assert libs. Raised #480 to remove others.

@@ -2,8 +2,10 @@ package statsd

import (
"context"
"github.com/stretchr/testify/assert"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a check somewhere for this, not sure why the build didn't hit it. Import ordering is:

  • stdlib
  • 3rd party
  • local

@rubenruizdegauna
Copy link
Contributor Author

rubenruizdegauna commented Mar 21, 2022

Thanks @aelse @tiedotguy for the quick review. I have made the requested changes in b17ebf5

@aelse
Copy link
Member

aelse commented Mar 21, 2022

lgtm. If @tiedotguy is happy we can merge.

@rubenruizdegauna
Copy link
Contributor Author

lgtm. If @tiedotguy is happy we can merge.

Hi @tiedotguy , do you think this can be merged? Thanks!

@tiedotguy tiedotguy merged commit 4366039 into atlassian:master Mar 28, 2022
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.

3 participants