Skip to content

Commit

Permalink
[v2-10-test] Allow "/" in metrics validator (#42934) (#44515)
Browse files Browse the repository at this point in the history
* Allow "/" to avoid ERROR - Invalid stat name: dag_processing.processes,file_path=/mnt/c

* Add UT

* Reformat
(cherry picked from commit 14b32ea)

Co-authored-by: awdavidson <54780428+awdavidson@users.noreply.github.com>
  • Loading branch information
2 people authored and utkarsharma2 committed Dec 9, 2024
1 parent 84d8a54 commit 24389df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airflow/metrics/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/core/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 24389df

Please sign in to comment.