diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py index 111ad9b87df62..d69e57762c23a 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 diff --git a/tests/core/test_stats.py b/tests/core/test_stats.py index 902a0ed0037f5..e0386cab1b911 100644 --- a/tests/core/test_stats.py +++ b/tests/core/test_stats.py @@ -506,6 +506,10 @@ 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",