DataDog / dogstatsd-ruby

A Ruby client for DogStatsd
https://www.datadoghq.com/
MIT License
179 stars 137 forks source link

UDS test suite fails and client does not work when sending on UDS on at least macOS 13.3.1 #275

Closed crankycoder closed 1 year ago

crankycoder commented 1 year ago

When testing the dogstatsd client with domain sockets - I'm unable to get the client (5.5.0) to communicate to my netcat domain socket.

I'm running this shell script to spin up a listener:

#!/bin/sh

rm -rf /tmp/var/run/datadog/dsd.socket
mkdir -p /tmp/var/run/datadog
nc -lUk /tmp/var/run/datadog/dsd.socket

My ruby code reads:

irb(main):001:0> require 'datadog/statsd'
=> true
irb(main):002:0> statsd = ::Datadog::Statsd.new(socket_path: '/tmp/var/run/datadog/dsd.so
cket', single_thread: true)
=> 
#<Datadog::Statsd:0x000000010e9d6638
...
irb(main):003:0> statsd.increment('foo')
=> nil
irb(main):004:0> statsd.flush
=> 0

I see no metrics on my UDP listener.

I can see metrics if I manually send data to the socket:

❯ echo "foo:1|c" | nc -U /tmp/var/run/datadog/dsd.socket

Additionally - the test suite seems to have marked all Unix Domain Socket (uds) tests as pending:

Finished in 1 minute 19.37 seconds (files took 0.235 seconds to load)
576 examples, 0 failures, 15 pending

Tests marked as pending are also skipped in CI: https://app.circleci.com/pipelines/github/DataDog/dogstatsd-ruby/162/workflows/80ccdb50-b50d-45e2-be25-6d1a8fdb4881/jobs/1256

so this does not appear to be a problem with my machine. Does DogstatsD not support domain sockets officially?

crankycoder commented 1 year ago

While writing my patch - I discovered that this looks more like a "testsuite is giving false positive pass".

I can't for the life of me figure out why the existing code does not work, but the UNIXSocket code does work for me.

crankycoder commented 1 year ago

closing: macos nc doesn't run domain sockets in datagram mode - only stream mode .