Skip to content

Commit

Permalink
if check before deleting in remove() (#1077)
Browse files Browse the repository at this point in the history
Signed-off-by: GlorifiedPig <[email protected]>
  • Loading branch information
GlorifiedPig authored Dec 6, 2024
1 parent ef95c4b commit 92b2397
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion prometheus_client/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def remove(self, *labelvalues: Any) -> None:
raise ValueError('Incorrect label count (expected %d, got %s)' % (len(self._labelnames), labelvalues))
labelvalues = tuple(str(l) for l in labelvalues)
with self._lock:
del self._metrics[labelvalues]
if labelvalues in self._metrics:
del self._metrics[labelvalues]

def clear(self) -> None:
"""Remove all labelsets from the metric"""
Expand Down

0 comments on commit 92b2397

Please sign in to comment.