You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2024/11/30 15:52:52 UTC
(airflow) branch main updated: Allow "/" in metrics validator (#42934)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 14b32eae676 Allow "/" in metrics validator (#42934)
14b32eae676 is described below
commit 14b32eae6761075a9546647f47ba35705c9bac03
Author: awdavidson <54...@users.noreply.github.com>
AuthorDate: Sat Nov 30 15:52:45 2024 +0000
Allow "/" in metrics validator (#42934)
* Allow "/" to avoid ERROR - Invalid stat name: dag_processing.processes,file_path=/mnt/c
* Add UT
* Reformat
---
airflow/metrics/validators.py | 2 +-
tests/core/test_stats.py | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py
index a570721ffe2..594a1a9d9e2 100644
--- a/airflow/metrics/validators.py
+++ b/airflow/metrics/validators.py
@@ -46,7 +46,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
diff --git a/tests/core/test_stats.py b/tests/core/test_stats.py
index 92b4b63f7b6..dc2d6095fc3 100644
--- a/tests/core/test_stats.py
+++ b/tests/core/test_stats.py
@@ -472,6 +472,10 @@ class TestStatsWithInfluxDBEnabled:
)
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",