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

Add statsdreceiver Unixgram Support #36608

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
remove socket deletion
  • Loading branch information
michaelli321 committed Dec 13, 2024
commit 365d90d5a3391f80f637cff23a3cec6c959aa72d
18 changes: 0 additions & 18 deletions receiver/statsdreceiver/internal/transport/uds_server.go
Original file line number Diff line number Diff line change
@@ -22,10 +22,6 @@ func NewUDSServer(transport Transport, socketPath string) (Server, error) {
return nil, fmt.Errorf("NewUDSServer with %s: %w", transport.String(), ErrUnsupportedPacketTransport)
}

if err := prepareSocket(socketPath); err != nil {
return nil, err
}

conn, err := net.ListenPacket(transport.String(), socketPath)
if err != nil {
return nil, fmt.Errorf("starting to listen %s socket: %w", transport.String(), err)
@@ -44,17 +40,3 @@ func (u *udsServer) Close() error {
os.Remove(u.packetConn.LocalAddr().String())
return u.packetConn.Close()
}

func prepareSocket(socketPath string) error {
if _, err := os.Stat(socketPath); err == nil {
// File exists, remove it
if err = os.Remove(socketPath); err != nil {
return fmt.Errorf("failed to remove existing socket file: %w", err)
}
} else if !os.IsNotExist(err) {
// Return any error that's not "file does not exist"
return fmt.Errorf("failed to stat socket file: %w", err)
}

return nil
}