From a90d04dc1c7d7dbf3d2eb3515580a278a9c1dea0 Mon Sep 17 00:00:00 2001 From: Alfred Davidson Date: Fri, 11 Oct 2024 10:47:20 +0100 Subject: [PATCH 1/3] Allow "/" to avoid ERROR - Invalid stat name: dag_processing.processes,file_path=/mnt/c --- airflow/metrics/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py index b47cdac1be551..f697327d6ab66 100644 --- a/airflow/metrics/validators.py +++ b/airflow/metrics/validators.py @@ -44,7 +44,7 @@ class MetricNameLengthExemptionWarning(Warning): # Only characters in the character set are considered valid # for the stat_name if stat_name_default_handler is used. -ALLOWED_CHARACTERS = frozenset(string.ascii_letters + string.digits + "_.-") +ALLOWED_CHARACTERS = frozenset(string.ascii_letters + string.digits + "_.-/") # The following set contains existing metrics whose names are too long for # OpenTelemetry and should be deprecated over time. This is implemented to From 6ff5a144988547a4a11e349fb9e8524620f0c747 Mon Sep 17 00:00:00 2001 From: Alfred Davidson Date: Sun, 24 Nov 2024 09:08:36 +0000 Subject: [PATCH 2/3] Add UT --- tests/core/test_stats.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/core/test_stats.py b/tests/core/test_stats.py index 9a218010a189e..e7a2a7db8c97a 100644 --- a/tests/core/test_stats.py +++ b/tests/core/test_stats.py @@ -489,6 +489,13 @@ def test_increment_counter_with_tags(self): ) self.statsd_client.incr.assert_called_once_with("test_stats_run.delay,key0=0,key1=val1", 1, 1) + def test_increment_counter_with_tags_and_forward_slash(self): + self.stats.incr( + "test_stats_run.dag", + tags={"path": "/some/path/dag.py"} + ) + self.statsd_client.incr.assert_called_once_with("test_stats_run.dag,path=/some/path/dag.py", 1, 1) + def test_does_not_increment_counter_drops_invalid_tags(self): self.stats.incr( "test_stats_run.delay", From b1839adf61362fd272d2b872160a36475ad1d55d Mon Sep 17 00:00:00 2001 From: Alfred Davidson Date: Sat, 30 Nov 2024 10:22:54 +0000 Subject: [PATCH 3/3] Reformat --- tests/core/test_stats.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/core/test_stats.py b/tests/core/test_stats.py index e7a2a7db8c97a..937f85996fd2f 100644 --- a/tests/core/test_stats.py +++ b/tests/core/test_stats.py @@ -490,10 +490,7 @@ def test_increment_counter_with_tags(self): self.statsd_client.incr.assert_called_once_with("test_stats_run.delay,key0=0,key1=val1", 1, 1) def test_increment_counter_with_tags_and_forward_slash(self): - self.stats.incr( - "test_stats_run.dag", - tags={"path": "/some/path/dag.py"} - ) + self.stats.incr("test_stats_run.dag", tags={"path": "/some/path/dag.py"}) self.statsd_client.incr.assert_called_once_with("test_stats_run.dag,path=/some/path/dag.py", 1, 1) def test_does_not_increment_counter_drops_invalid_tags(self):