fix: sanitize Dag processor metric file names#67029
Open
anmolxlight wants to merge 1 commit into
Open
Conversation
Contributor
SameerMesiah97
left a comment
There was a problem hiding this comment.
Looks fine. Just one question and a tiny nit.
| ) | ||
|
|
||
| @mock.patch("airflow.dag_processing.manager.stats.gauge") | ||
| def test_log_file_processing_stats_sanitizes_last_run_seconds_ago_metric_name(self, statsd_gauge_mock): |
Contributor
There was a problem hiding this comment.
Suggested change
| def test_log_file_processing_stats_sanitizes_last_run_seconds_ago_metric_name(self, statsd_gauge_mock): | |
| def test_log_file_processing_stats_normalizes_metric_name(self, statsd_gauge_mock): |
| num_dags = stat.num_dags | ||
| num_errors = stat.import_errors | ||
| file_name = Path(file.rel_path).stem | ||
| file_name = normalize_name_for_stats(Path(file.rel_path).stem) |
Contributor
There was a problem hiding this comment.
Is _log_file_processing_stats() the only place where Dag file names are incorporated into metric names?
Since the bug is fundamentally about unsanitized file-derived metric segments, it’d be good to verify there aren’t other DAG-processing stats paths still using Path(...).stem or rel_path directly without normalize_name_for_stats().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dag_processing.last_run.seconds_ago.*metric names.Test Plan
uv run --project airflow-core pytest airflow-core/tests/unit/dag_processing/test_manager.py::TestDagFileProcessorManager::test_log_file_processing_stats_sanitizes_last_run_seconds_ago_metric_name -xvsuv run --project airflow-core pytest airflow-core/tests/unit/dag_processing/test_manager.py::TestDagFileProcessorManager::test_send_file_processing_statsd_timing airflow-core/tests/unit/dag_processing/test_manager.py::TestDagFileProcessorManager::test_log_file_processing_stats_sanitizes_last_run_seconds_ago_metric_name -quv run --project airflow-core pytest airflow-core/tests/unit/dag_processing/test_manager.py -quv run prek run ruff --files airflow-core/src/airflow/dag_processing/manager.py airflow-core/tests/unit/dag_processing/test_manager.pyuv run prek run ruff-format --files airflow-core/src/airflow/dag_processing/manager.py airflow-core/tests/unit/dag_processing/test_manager.pyCloses #67028