Repository navigation
Support a Unix Domain Socket for the metrics clients - #70517
Conversation
844b919 to
b4dcbec
Compare
uranusjr
left a comment
There was a problem hiding this comment.
It is too implicit to me that the path silently takes precedence over host+port. An exception should be raised probably when both are set.
We can fix that by making the host/port nullable and removing the default values. But then we need to reintroduce the default values at the metrics loggers because we don't want to break existing configurations that just enable metrics but don't specify host and port. I'll do that |
4c1c550 to
c105ef7
Compare
|
Having configured all of the options For datadog, the same class accepts all of them and then silently gives precedence to the For statsd, each config option is used for a different class but all of them could co-exist. If both classes are instantiated, the same metric will be emitted twice which isn't optimal or desired but still there won't be an issue for the system. IMO, we shouldn't set |
c105ef7 to
fcdee0c
Compare
fcdee0c to
f7b3331
Compare
|
@xBis7, makes sense. No exception anymore. |
91044a2 to
5ad1e00
Compare
666cf2f to
5cf9fdf
Compare
|
@uranusjr, do you want me to go for the observability lib depending on the config lib? |
|
@sortega Thanks for updating the PR! If you need a new exception type, then it needs to be added here instead of adding a new dependency But, I don't think we should do that. So, if you need to do a validation which will throw an You don't have to move the entire thing, just do a quick validation regarding the config value and the rest stays the same. |
5cf9fdf to
7422272
Compare
6aded0a to
55e8e5c
Compare
55e8e5c to
5939d84
Compare
uranusjr
left a comment
There was a problem hiding this comment.
A few minor issues this need to fix before the PR is mergeable.
4baf5a6 to
ecbe5b9
Compare
xBis7
left a comment
There was a problem hiding this comment.
I have 2 non-blocking questions. LGTM!
hussein-awala
left a comment
There was a problem hiding this comment.
Overall the change looks good, add a few comments, LGTM once they are addressed.
74fa104 to
36e5323
Compare
Airflow's metrics clients could only be pointed at a host and port, so deployments that expose the daemon over a Unix Domain Socket (for example the Datadog Kubernetes operator, which mounts a socket and sets DD_DOGSTATSD_URL) had no way to use it from Airflow. Add a ``[metrics] statsd_socket_path`` option, honored by both backends: the DataDog client is built with ``socket_path`` and the StatsD client uses ``statsd.UnixSocketStatsClient``. ``statsd_host`` and ``statsd_port`` are now nullable, and only explicitly-configured values are passed to the client; when nothing is set the DataDog client falls back to its own environment variables (DD_AGENT_HOST / DD_DOGSTATSD_URL). ``statsd_socket_path`` takes precedence over ``statsd_host`` / ``statsd_port`` when both are set — the DataDog client is given all of them and prefers the socket, the StatsD client is built on the socket — and a warning is logged in that case.
36e5323 to
7bdedfb
Compare
Adds a `[metrics] statsd_socket_path` option so Airflow can submit metrics over a Unix Domain Socket instead of host/port — for both the StatsD and DataDog backends.
Today `get_statsd_logger` / `get_dogstatsd_logger` only pass `statsd_host` / `statsd_port`, so deployments that expose the daemon over a UDS — e.g. the Datadog Kubernetes operator, which mounts a socket and sets `DD_DOGSTATSD_URL=unix:///var/run/datadog/dsd.socket` — have no way to use it from Airflow. Both `datadog.DogStatsd` and the `statsd` library (`UnixSocketStatsClient`) support a socket path; this exposes it through Airflow config.
`statsd_host` and `statsd_port` keep their existing defaults (`localhost` / `8125`). When `statsd_socket_path` is set it takes precedence and host/port are ignored:
When `statsd_socket_path` is unset, behavior is identical to before.
Closes #70666
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8 1M) following the guidelines