C_Z_
C_Z_

Reputation: 7796

Prometheus Python see current value of metric

From the prometheus python documentation, let's say I run this:

from prometheus_client import Counter
c = Counter('my_failures', 'Description of counter')
c.inc()     # Increment by 1
c.inc(1.6)  # Increment by given value

How might I get the value of the c metric after performing both of these increments? This is for testing purposes, I want to be able to test

c.value == 2.6

Except I can't seem to find a value accessor.

Is this even possible, or should I find another way?

Upvotes: 1

Views: 4439

Answers (1)

ywbaek
ywbaek

Reputation: 3031

From the source code, it looks like you can access it by _value attribute:

c._value.get() == 2.6

Upvotes: 4

Related Questions