xBis7 commented on code in PR #63932:
URL: https://github.com/apache/airflow/pull/63932#discussion_r3125008033


##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -1863,8 +1863,10 @@ def main():
     global SUPERVISOR_COMMS
     SUPERVISOR_COMMS = CommsDecoder[ToTask, ToSupervisor](log=log)
 
-    stats_factory = stats_utils.get_stats_factory(Stats)
-    Stats.initialize(factory=stats_factory)
+    stats.initialize(
+        factory=stats_utils.get_stats_factory(),

Review Comment:
   The issue is that any code under `shared` doesn't have access to the airflow 
conf. So, both `airflow-core` and `task-sdk` need to read the config, get the 
correct values and use them to initialize `stats` which live under `shared`.
   
   `stats_utils.get_stats_factory()` reads conf, initializes the correct 
factory and then passes it to `stats`.
   
   That's the reason why there is code duplication in these directories
   
   
https://github.com/xBis7/airflow/tree/simplify-stats/airflow-core/src/airflow/observability/metrics
   
   
https://github.com/xBis7/airflow/tree/simplify-stats/task-sdk/src/airflow/sdk/observability/metrics
   
   For example,
   
   
https://github.com/xBis7/airflow/blob/simplify-stats/airflow-core/src/airflow/observability/metrics/otel_logger.py
   
   and
   
   
https://github.com/xBis7/airflow/blob/simplify-stats/task-sdk/src/airflow/sdk/observability/metrics/otel_logger.py
   
   All the files are the same and the only difference is in the imports.



##########
task-sdk/src/airflow/sdk/observability/metrics/datadog_logger.py:
##########


Review Comment:
   Same explanation
   
   https://github.com/apache/airflow/pull/63932#discussion_r3125008033



##########
task-sdk/src/airflow/sdk/observability/metrics/stats_utils.py:
##########


Review Comment:
   Same explanation
   
   https://github.com/apache/airflow/pull/63932#discussion_r3125008033



-- 
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