Пример #1
0
    def test_scalar(self):
        counter = CounterMetric("scalar")

        self.assertEquals(counter.render(), [
            'scalar 0',
        ])

        counter.inc()

        self.assertEquals(counter.render(), [
            'scalar 1',
        ])

        counter.inc_by(2)

        self.assertEquals(counter.render(), ['scalar 3'])
Пример #2
0
    def test_scalar(self):
        counter = CounterMetric("scalar")

        self.assertEquals(counter.render(), [
            'scalar 0',
        ])

        counter.inc()

        self.assertEquals(counter.render(), [
            'scalar 1',
        ])

        counter.inc_by(2)

        self.assertEquals(counter.render(), [
            'scalar 3'
        ])
Пример #3
0
    def test_vector(self):
        counter = CounterMetric("vector", labels=["method"])

        # Empty counter doesn't yet know what values it has
        self.assertEquals(counter.render(), [])

        counter.inc("GET")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 1',
        ])

        counter.inc("GET")
        counter.inc("PUT")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 2',
            'vector{method="PUT"} 1',
        ])
Пример #4
0
    def test_vector(self):
        counter = CounterMetric("vector", labels=["method"])

        # Empty counter doesn't yet know what values it has
        self.assertEquals(counter.render(), [])

        counter.inc("GET")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 1',
        ])

        counter.inc("GET")
        counter.inc("PUT")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 2',
            'vector{method="PUT"} 1',
        ])
Пример #5
0
    def test_vector(self):
        counter = CounterMetric("vector", labels=["method"])

        # Empty counter doesn't yet know what values it has
        self.assertEquals(counter.render(), [])

        counter.inc("GET")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 1',
        ])

        counter.inc("GET")
        counter.inc("PUT")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 2',
            'vector{method="PUT"} 1',
        ])

        # Check that passing too few values errors
        self.assertRaises(ValueError, counter.inc)
Пример #6
0
    def test_vector(self):
        counter = CounterMetric("vector", labels=["method"])

        # Empty counter doesn't yet know what values it has
        self.assertEquals(counter.render(), [])

        counter.inc("GET")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 1',
        ])

        counter.inc("GET")
        counter.inc("PUT")

        self.assertEquals(counter.render(), [
            'vector{method="GET"} 2',
            'vector{method="PUT"} 1',
        ])

        # Check that passing too few values errors
        self.assertRaises(ValueError, counter.inc)