10000 Merge pull request #658 from prometheus/beorn7/doc · lvillis/client_python@e18828f · GitHub
[go: up one dir, main page]

Skip to content

Commit e18828f

Browse files
authored
Merge pull request prometheus#658 from prometheus/beorn7/doc
Document implications of negative observations
2 parents 9118c02 + 13f786a commit e18828f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

prometheus_client/metrics.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,15 @@ def _metric_init(self):
441441
self._created = time.time()
442442

443443
def observe(self, amount):
444-
"""Observe the given amount."""
444+
"""Observe the given amount.
445+
446+
The amount is usually positive or zero. Negative values are
447+
accepted but prevent current versions of Prometheus from
448+
properly detecting counter resets in the sum of
449+
observations. See
450+
https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
451+
for details.
452+
"""
445453
self._count.inc(1)
446454
self._sum.inc(amount)
447455

@@ -550,7 +558,15 @@ def _metric_init(self):
550558
)
551559

552560
def observe(self, amount):
553-
"""Observe the given amount."""
561+
"""Observe the given amount.
562+
563+
The amount is usually positive or zero. Negative values are
564+
accepted but prevent current versions of Prometheus from
565+
properly detecting counter resets in the sum of
566+
observations. See
567+
https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
568+
for details.
569+
"""
554570
self._sum.inc(amount)
555571
for i, bound in enumerate(self._upper_bounds):
556572
if amount <= bound:

0 commit comments

Comments
 (0)
0