This is an automated email from the ASF dual-hosted git repository.

utkarsharma pushed a commit to branch v2-9-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 52e447b6f661b09b147402846151e4130e41418f
Author: Duc Le Tu <[email protected]>
AuthorDate: Tue Jun 25 16:34:38 2024 +0700

    fix(statsd): handle unsupport operand int + str when value of tag is int 
(job_id) (#40407)
    
    (cherry picked from commit 19baf9c60553ca7ae5af466f94f2bb23ee306df8)
---
 airflow/metrics/statsd_logger.py | 2 +-
 tests/core/test_stats.py         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/airflow/metrics/statsd_logger.py b/airflow/metrics/statsd_logger.py
index 5b04c0b95a..ecd6cfc231 100644
--- a/airflow/metrics/statsd_logger.py
+++ b/airflow/metrics/statsd_logger.py
@@ -55,7 +55,7 @@ def prepare_stat_with_tags(fn: T) -> T:
             if stat is not None and tags is not None:
                 for k, v in tags.items():
                     if self.metric_tags_validator.test(k):
-                        if all(c not in [",", "="] for c in v + k):
+                        if all(c not in [",", "="] for c in f"{v}{k}"):
                             stat += f",{k}={v}"
                         else:
                             log.error("Dropping invalid tag: %s=%s.", k, v)
diff --git a/tests/core/test_stats.py b/tests/core/test_stats.py
index 4c8f6fb1d7..d8d3f6901e 100644
--- a/tests/core/test_stats.py
+++ b/tests/core/test_stats.py
@@ -487,9 +487,9 @@ class TestStatsWithInfluxDBEnabled:
     def test_increment_counter_with_tags(self):
         self.stats.incr(
             "test_stats_run.delay",
-            tags={"key0": "val0", "key1": "val1", "key2": "val2"},
+            tags={"key0": 0, "key1": "val1", "key2": "val2"},
         )
-        
self.statsd_client.incr.assert_called_once_with("test_stats_run.delay,key0=val0,key1=val1",
 1, 1)
+        
self.statsd_client.incr.assert_called_once_with("test_stats_run.delay,key0=0,key1=val1",
 1, 1)
 
     def test_does_not_increment_counter_drops_invalid_tags(self):
         self.stats.incr(

Reply via email to