Skip to content

Commit

Permalink
Refactor: Simplify dict manipulation in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
eumiro committed Aug 9, 2023
1 parent e114312 commit 762a491
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions airflow/metrics/otel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,9 @@ def get_counter(self, name: str, attributes: Attributes = None):
: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:
"""
Expand Down

0 comments on commit 762a491

Please sign in to comment.