Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Simplify dict manipulation in metrics #33264

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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