MCPcopy Index your code
hub / github.com/prometheus/client_python / inc

Method inc

prometheus_client/metrics.py:335–343  ·  view source on GitHub ↗

Increment counter by the given amount.

(self, amount: float = 1, exemplar: Optional[Dict[str, str]] = None)

Source from the content-addressed store, hash-verified

333 self._created = time.time()
334
335 def inc(self, amount: float = 1, exemplar: Optional[Dict[str, str]] = None) -> None:
336 """Increment counter by the given amount."""
337 self._raise_if_not_observable()
338 if amount < 0:
339 raise ValueError('Counters can only be incremented by non-negative amounts.')
340 self._value.inc(amount)
341 if exemplar:
342 _validate_exemplar(exemplar)
343 self._value.set_exemplar(Exemplar(exemplar, amount, time.time()))
344
345 def reset(self) -> None:
346 """Reset the counter to zero. Use this when a logical process restarts without restarting the actual python process."""

Callers 15

test_counter_addsMethod · 0.95
test_counterMethod · 0.95
test_counter_utf8Method · 0.95
test_counter_totalMethod · 0.95
setUpMethod · 0.95
increment_metricsMethod · 0.95
test_counterMethod · 0.95

Calls 6

_validate_exemplarFunction · 0.85
ExemplarClass · 0.85
incMethod · 0.45
set_exemplarMethod · 0.45
timeMethod · 0.45

Tested by 15

test_counter_addsMethod · 0.76
test_counterMethod · 0.76
test_counter_utf8Method · 0.76
test_counter_totalMethod · 0.76
setUpMethod · 0.76
increment_metricsMethod · 0.76
test_counterMethod · 0.76