Skip to content

Commit 8445422

Browse files
Stop dag processor from warning on every file path normalized for stats (#71091)
* Stop dag processor from warning on every file path normalized for stats * Apply suggestions from code review Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com> --------- Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
1 parent f8b8461 commit 8445422

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

airflow-core/src/airflow/dag_processing/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def presence_key(self) -> tuple[str, Path]:
155155
@property
156156
def normalized_file_path_for_stats(self) -> str:
157157
"""Return the relative file path normalized for use in stats tags."""
158-
return normalize_name_for_stats(str(self.rel_path))
158+
return normalize_name_for_stats(str(self.rel_path), log_warning=False)
159159

160160

161161
def _config_int_factory(section: str, key: str):

airflow-core/tests/unit/dag_processing/test_manager.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,3 +3802,20 @@ def test_get_team_names_batches_and_caches(self, mock_get_team_names):
38023802
# Two bundles resolved in a single batched query; the repeat call is served from cache.
38033803
mock_get_team_names.assert_called_once()
38043804
assert manager._bundle_name_to_team_name == {"bundle_a": "team_alpha", "bundle_b": "team_alpha"}
3805+
3806+
3807+
def test_normalized_file_path_for_stats_does_not_warn(caplog):
3808+
"""
3809+
rel_path always contains "/" for any nested DAG file, so normalizing it for stats
3810+
always requires substitution -- this must not log a warning on every DAG file, every
3811+
processing cycle.
3812+
"""
3813+
dag_file_info = DagFileInfo(
3814+
bundle_name="testing", bundle_path=TEST_DAGS_FOLDER, rel_path=Path("dags/test/test_dag.py")
3815+
)
3816+
3817+
with caplog.at_level(logging.WARNING, logger="airflow._shared.observability.metrics.stats"):
3818+
result = dag_file_info.normalized_file_path_for_stats
3819+
3820+
assert result == "dags_test_test_dag.py"
3821+
assert caplog.entries == []

0 commit comments

Comments
 (0)