From b9a12253dc04bc57a8f877cb94f5a631cee33a69 Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 10 Dec 2018 22:14:02 -0700 Subject: [PATCH] Update prometheus-client package to 0.5.0 The update involved some refactoring on their end that eliminated _LabelWrapper, so this required a minor change (but I don't know why I was doing it that way in the first place). --- tildes/requirements.txt | 2 +- tildes/tildes/metrics.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tildes/requirements.txt b/tildes/requirements.txt index be9868d..0e34369 100644 --- a/tildes/requirements.txt +++ b/tildes/requirements.txt @@ -44,7 +44,7 @@ Pillow==5.3.0 plaster==1.0 plaster-pastedeploy==0.6 pluggy==0.8.0 -prometheus-client==0.4.2 +prometheus-client==0.5.0 prompt-toolkit==2.0.7 prospector==1.1.6.2 psycopg2==2.7.6.1 diff --git a/tildes/tildes/metrics.py b/tildes/tildes/metrics.py index 0635a38..442508d 100644 --- a/tildes/tildes/metrics.py +++ b/tildes/tildes/metrics.py @@ -10,7 +10,6 @@ from typing import Callable from prometheus_client import Counter, Histogram -from prometheus_client.core import _LabelWrapper _COUNTERS = { @@ -50,7 +49,7 @@ def incr_counter(name: str, amount: int = 1, **labels: str) -> None: except KeyError: raise ValueError("Invalid counter name") - if isinstance(counter, _LabelWrapper): + if labels: counter = counter.labels(**labels) counter.inc(amount) @@ -63,7 +62,7 @@ def get_histogram(name: str, **labels: str) -> Histogram: except KeyError: raise ValueError("Invalid histogram name") - if isinstance(hist, _LabelWrapper): + if labels: hist = hist.labels(**labels) return hist