This is an automated email from the ASF dual-hosted git repository.
uranusjr 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 01a6c1e7f8 Refactor: Simplify dict manipulation in metrics (#33264)
01a6c1e7f8 is described below
commit 01a6c1e7f8b0ed736d7c6f661e0c29ec023016b2
Author: Miroslav Šedivý <[email protected]>
AuthorDate: Thu Aug 10 07:08:19 2023 +0000
Refactor: Simplify dict manipulation in metrics (#33264)
---
airflow/metrics/otel_logger.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/airflow/metrics/otel_logger.py b/airflow/metrics/otel_logger.py
index 3168e9ae65..3e4701ca60 100644
--- a/airflow/metrics/otel_logger.py
+++ b/airflow/metrics/otel_logger.py
@@ -309,12 +309,9 @@ class MetricsMap:
:param attributes: Counter attributes, used to generate a unique key
to store the counter.
"""
key = _generate_key_name(name, attributes)
- if key in self.map.keys():
- return self.map[key]
- else:
- new_counter = self._create_counter(name)
- self.map[key] = new_counter
- return new_counter
+ if key not in self.map:
+ self.map[key] = self._create_counter(name)
+ return self.map[key]
def del_counter(self, name: str, attributes: Attributes = None) -> None:
"""