Browse Source

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).
merge-requests/53/head
Deimos 6 years ago
parent
commit
b9a12253dc
  1. 2
      tildes/requirements.txt
  2. 5
      tildes/tildes/metrics.py

2
tildes/requirements.txt

@ -44,7 +44,7 @@ Pillow==5.3.0
plaster==1.0 plaster==1.0
plaster-pastedeploy==0.6 plaster-pastedeploy==0.6
pluggy==0.8.0 pluggy==0.8.0
prometheus-client==0.4.2
prometheus-client==0.5.0
prompt-toolkit==2.0.7 prompt-toolkit==2.0.7
prospector==1.1.6.2 prospector==1.1.6.2
psycopg2==2.7.6.1 psycopg2==2.7.6.1

5
tildes/tildes/metrics.py

@ -10,7 +10,6 @@
from typing import Callable from typing import Callable
from prometheus_client import Counter, Histogram from prometheus_client import Counter, Histogram
from prometheus_client.core import _LabelWrapper
_COUNTERS = { _COUNTERS = {
@ -50,7 +49,7 @@ def incr_counter(name: str, amount: int = 1, **labels: str) -> None:
except KeyError: except KeyError:
raise ValueError("Invalid counter name") raise ValueError("Invalid counter name")
if isinstance(counter, _LabelWrapper):
if labels:
counter = counter.labels(**labels) counter = counter.labels(**labels)
counter.inc(amount) counter.inc(amount)
@ -63,7 +62,7 @@ def get_histogram(name: str, **labels: str) -> Histogram:
except KeyError: except KeyError:
raise ValueError("Invalid histogram name") raise ValueError("Invalid histogram name")
if isinstance(hist, _LabelWrapper):
if labels:
hist = hist.labels(**labels) hist = hist.labels(**labels)
return hist return hist

Loading…
Cancel
Save