pierrejeambrun commented on code in PR #69270:
URL: https://github.com/apache/airflow/pull/69270#discussion_r3644621773
##########
airflow-core/src/airflow/observability/metrics/stats_utils.py:
##########
@@ -37,3 +37,21 @@ def get_stats_factory() -> Callable:
return otel_logger.get_otel_logger
return NoStatsLogger
+
+
+def initialize_sdk_stats_backend() -> None:
+ """
+ Initialize the task-sdk ``Stats`` singleton with this process's configured
backend.
+
+ Plugins and listener hooks commonly get ``Stats`` via
``airflow.sdk.observability.stats``
+ (or the deprecated ``airflow.stats`` shim, which re-exports the same
module). That module
+ is a separate singleton from the one this process initializes for its own
internal use, so
+ it must be initialized here too, or plugin code silently falls back to
``NoStatsLogger`` in
+ any long-running component other than the task runner.
+ """
+ from airflow.sdk.observability import stats as sdk_stats # noqa: SDK001
Review Comment:
This makes core dependent on sdk client. We're splitting those two and this
probably isn't the way to go.
##########
airflow-core/newsfragments/69270.bugfix.rst:
##########
Review Comment:
remove this file please.
##########
airflow-core/src/airflow/executors/base_executor.py:
##########
@@ -215,6 +215,7 @@ def __init__(self, parallelism: int = PARALLELISM,
team_name: str | None = None)
factory=stats_utils.get_stats_factory(),
export_legacy_names=conf.getboolean("metrics", "legacy_names_on"),
)
+ stats_utils.initialize_sdk_stats_backend()
Review Comment:
Compared to api calls, these aren't guarded with an exception catcher.
Metric init failure will fail the executor / scheduler etc...
--
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]