uranusjr commented on code in PR #70517:
URL: https://github.com/apache/airflow/pull/70517#discussion_r3762507983


##########
airflow-core/src/airflow/observability/metrics/statsd_logger.py:
##########
@@ -31,26 +31,28 @@
 
 def get_statsd_logger() -> SafeStatsdLogger:
     stats_class = conf.getimport("metrics", "statsd_custom_client_path", 
fallback=None)
+    socket_path = conf.get("metrics", "statsd_socket_path", fallback=None)
 
     # no need to check for the scheduler/statsd_on -> this method is only 
called when it is set
     # and previously it would crash with None is callable if it was called 
without it.
-    from statsd import StatsClient
+    from statsd import StatsClient, UnixSocketStatsClient
 
     if stats_class:
-        if not issubclass(stats_class, StatsClient):
+        if not (issubclass(stats_class, StatsClient) or 
issubclass(stats_class, UnixSocketStatsClient)):

Review Comment:
   ```suggestion
           if not issubclass(stats_class, (StatsClient, UnixSocketStatsClient)):
   ```
   
   More importantly, passing this check doesn't mean the class works in socket 
mode. A custom client that subclasses `StatsClient` is accepted, and 
`get_statsd_logger` then calls it as `stats_class(socket_path=..., 
prefix=...)`. Combining `statsd_custom_client_path` with `statsd_socket_path` 
is an unhandled `TypeError` at startup, with nothing pointing at the two 
settings that conflict.
   
   Could we require `UnixSocketStatsClient` specifically when `socket_path` is 
set, and raise `AirflowConfigException` otherwise?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to