-
Notifications
You must be signed in to change notification settings - Fork 17.2k
fix: sanitize Dag processor metric file names #67029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anmolxlight
wants to merge
1
commit into
apache:main
Choose a base branch
from
anmolxlight:fix/67028-dag-processing-metric-names
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+20
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1359,6 +1359,25 @@ def test_send_file_processing_statsd_timing( | |||||
| tags={"bundle_name": bundle_name, "file_name": dag_filename[:-3]}, | ||||||
| ) | ||||||
|
|
||||||
| @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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| manager = DagFileProcessorManager(max_runs=1) | ||||||
| dag_file = DagFileInfo( | ||||||
| bundle_name="testing", | ||||||
| rel_path=Path("test_of sprak_opertaor.py"), | ||||||
| bundle_path=TEST_DAGS_FOLDER, | ||||||
| ) | ||||||
| manager._file_stats[dag_file] = DagFileStat( | ||||||
| last_finish_time=timezone.utcnow() - timedelta(seconds=5), | ||||||
| ) | ||||||
|
|
||||||
| manager._log_file_processing_stats({"testing": {dag_file}}) | ||||||
|
|
||||||
| statsd_gauge_mock.assert_any_call( | ||||||
| "dag_processing.last_run.seconds_ago.test_of_sprak_opertaor", | ||||||
| mock.ANY, | ||||||
| ) | ||||||
|
|
||||||
| @pytest.mark.usefixtures("testing_dag_bundle") | ||||||
| def test_refresh_dags_dir_doesnt_delete_zipped_dags( | ||||||
| self, tmp_path, session, configure_testing_dag_bundle, test_zip_path | ||||||
|
|
||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(...).stemorrel_pathdirectly withoutnormalize_name_for_stats().