diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-02-24 19:06:27 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-02-24 19:25:54 +0300 |
commit | cc1540c72837350cff1b97ae8f6556088946e45d (patch) | |
tree | 4d5ece470c72b304ec1a7b29dfb0f0a6aea07c15 /library/python | |
parent | b08a0cb057c1a81570f638038a0210dc167fa217 (diff) | |
download | ydb-cc1540c72837350cff1b97ae8f6556088946e45d.tar.gz |
Intermediate changes
commit_hash:175403568527edd57aee48e05da080129d67f6de
Diffstat (limited to 'library/python')
-rw-r--r-- | library/python/monlib/metric.pxd | 4 | ||||
-rw-r--r-- | library/python/monlib/metric.pyx | 6 | ||||
-rw-r--r-- | library/python/monlib/ut/py2/test.py | 10 | ||||
-rw-r--r-- | library/python/monlib/ut/py3/test.py | 10 |
4 files changed, 28 insertions, 2 deletions
diff --git a/library/python/monlib/metric.pxd b/library/python/monlib/metric.pxd index afa28ea015..a07dddfc93 100644 --- a/library/python/monlib/metric.pxd +++ b/library/python/monlib/metric.pxd @@ -48,9 +48,9 @@ cdef extern from "library/cpp/monlib/metrics/metric.h" namespace "NMonitoring" n cdef cppclass TCounter: TCounter(ui64 value) except + - void Set(ui64) ui64 Get() const - void Inc() + ui64 Add(ui64) + ui64 Inc() void Reset() cdef cppclass TRate: diff --git a/library/python/monlib/metric.pyx b/library/python/monlib/metric.pyx index 7b51752335..aad32596d9 100644 --- a/library/python/monlib/metric.pyx +++ b/library/python/monlib/metric.pyx @@ -103,6 +103,12 @@ cdef class Counter: """ return self.__wrapped.Inc() + def add(self, i64 value): + """ + Add value to metric + """ + return self.__wrapped.Add(value) + def reset(self): """ Reset metric value to zero diff --git a/library/python/monlib/ut/py2/test.py b/library/python/monlib/ut/py2/test.py index 4e389c47f1..0289168f04 100644 --- a/library/python/monlib/ut/py2/test.py +++ b/library/python/monlib/ut/py2/test.py @@ -252,6 +252,16 @@ def test_gauge_sensors(): assert ig.get() == 5 +def test_counter(): + registry = MetricRegistry() + c = registry.counter({'a': 'b'}) + + assert c.inc() == 1 + assert c.add(2) == 3 + c.reset() + assert c.get() == 0 + + UNISTAT_DATA = """[ ["signal1_max", 10], ["signal2_hgram", [[0, 100], [50, 200], [200, 300]]], diff --git a/library/python/monlib/ut/py3/test.py b/library/python/monlib/ut/py3/test.py index 5a68c1653e..bbb2b42bca 100644 --- a/library/python/monlib/ut/py3/test.py +++ b/library/python/monlib/ut/py3/test.py @@ -250,6 +250,16 @@ def test_gauge_sensors(): assert ig.get() == 5 +def test_counter(): + registry = MetricRegistry() + c = registry.counter({'a': 'b'}) + + assert c.inc() == 1 + assert c.add(2) == 3 + c.reset() + assert c.get() == 0 + + UNISTAT_DATA = """[ ["signal1_max", 10], ["signal2_hgram", [[0, 100], [50, 200], [200, 300]]], |