Ejemplo n.º 1
0
    def test_wildcard(self):
        self.create({"period": 0.1, "metrics": {"rails.{controller}.{action}.{0}": "*"}}, self.events)

        # 8 events expected - the above 6, and then 4 stat events
        q = self.wait(events=10)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(
            metric="rails.home.index.bytes",
            stats={
                "count": 3,
                "rate": between(1, 100),
                "max": 30159,
                "min": 6926,
                "median": 18150,
                "mean": 18411,
                "stddev": about(30789),
                "upper95": 28958.1,
                "upper99": 29918.82,
            },
            tags=["stat"],
        )
        assertEventEquals(self, expected, q[0])

        expected = Event(
            metric="rails.home.index.duration",
            stats={
                "count": 3,
                "rate": between(1, 100),
                "max": 4.0,
                "min": 3.0,
                "median": 3.5,
                "mean": 3.5,
                "stddev": 5.0,
                "upper95": 3.95,
                "upper99": 3.99,
            },
            tags=["stat"],
        )
        assertEventEquals(self, expected, q[1])

        expected = Event(
            metric="rails.home.login.duration",
            stats={
                "count": 1,
                "rate": between(1, 100),
                "max": 2.4,
                "min": 2.4,
                "median": 2.4,
                "mean": 2.4,
                "stddev": 0.0,
                "upper95": 2.4,
                "upper99": 2.4,
            },
            tags=["stat"],
        )
        assertEventEquals(self, expected, q[3])
Ejemplo n.º 2
0
    def test_wildcard(self):
        self.create({'period': 0.1, 'metrics': {'rails.{controller}.{action}.{0}': '*'}},
                    self.events)

        # 8 events expected - the above 6, and then 4 stat events
        q = self.wait(events=10)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(metric='rails.home.index.bytes',
                         stats={
                             'count': 3,
                             'rate': between(1, 100),
                             'max': 30159,
                             'min': 6926,
                             'median': 18150,
                             'mean': 18411,
                             'stddev': about(30789),
                             'upper95': 28958.1,
                             'upper99': 29918.82,
                         },
                         tags=['stat'],
                         )
        assertEventEquals(self, expected, q[0])

        expected = Event(metric='rails.home.index.duration',
                         stats={
                             'count': 3,
                             'rate': between(1, 100),
                             'max': 4.0,
                             'min': 3.0,
                             'median': 3.5,
                             'mean': 3.5,
                             'stddev': 5.0,
                             'upper95': 3.95,
                             'upper99': 3.99,
                         },
                         tags=['stat'],
                         )
        assertEventEquals(self, expected, q[1])

        expected = Event(metric='rails.home.login.duration',
                         stats={
                             'count': 1,
                             'rate': between(1, 100),
                             'max': 2.4,
                             'min': 2.4,
                             'median': 2.4,
                             'mean': 2.4,
                             'stddev': 0.0,
                             'upper95': 2.4,
                             'upper99': 2.4,
                         },
                         tags=['stat'],
                         )
        assertEventEquals(self, expected, q[3])
Ejemplo n.º 3
0
    def test_nested(self):
        self.create(
            {
                'period': 0.1,
                'metrics': {
                    'rails.{controller}.{action}.{0}': 'timings.*'
                }
            }, self.events)

        # 8 events expected - the above 6, and then 2 stat events
        q = self.wait(events=8)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(
            metric='rails.home.index.timings.view',
            stats={
                'count': 3,
                'max': 2.3,
                'mean': 1.5,
                'median': 1.2,
                'min': 1.0,
                'rate': between(1, 100),
                'stddev': about(2.34, 2),
                'upper95': 2.19,
                'upper99': 2.278
            },
            tags=['stat'],
        )
        assertEventEquals(self, expected, q[0])

        expected = Event(
            metric='rails.home.login.timings.view',
            stats={
                'count': 1,
                'max': 2.0,
                'mean': 2.0,
                'median': 2.0,
                'min': 2.0,
                'rate': between(1, 100),
                'stddev': 0.0,
                'upper95': 2.0,
                'upper99': 2.0
            },
            tags=['stat'],
        )
        assertEventEquals(self, expected, q[1])

        # wait for further two 'zero' stats
        q = self.wait(events=2)
Ejemplo n.º 4
0
    def test_nested(self):
        self.create({"period": 0.1, "metrics": {"rails.{controller}.{action}.{0}": "timings.*"}}, self.events)

        # 8 events expected - the above 6, and then 2 stat events
        q = self.wait(events=8)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(
            metric="rails.home.index.timings.view",
            stats={
                "count": 3,
                "max": 2.3,
                "mean": 1.5,
                "median": 1.2,
                "min": 1.0,
                "rate": between(1, 100),
                "stddev": about(2.34, 2),
                "upper95": 2.19,
                "upper99": 2.278,
            },
            tags=["stat"],
        )
        assertEventEquals(self, expected, q[0])

        expected = Event(
            metric="rails.home.login.timings.view",
            stats={
                "count": 1,
                "max": 2.0,
                "mean": 2.0,
                "median": 2.0,
                "min": 2.0,
                "rate": between(1, 100),
                "stddev": 0.0,
                "upper95": 2.0,
                "upper99": 2.0,
            },
            tags=["stat"],
        )
        assertEventEquals(self, expected, q[1])

        # wait for further two 'zero' stats
        q = self.wait(events=2)
Ejemplo n.º 5
0
    def test_nested(self):
        self.create({'period': 0.1, 'metrics': {'rails.{controller}.{action}.{0}': 'timings.*'}},
                    self.events)

        # 8 events expected - the above 6, and then 2 stat events
        q = self.wait(events=8)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(metric='rails.home.index.timings.view',
                         stats={
                             'count': 3,
                             'max': 2.3,
                             'mean': 1.5,
                             'median': 1.2,
                             'min': 1.0,
                             'rate': between(1, 100),
                             'stddev': about(2.34, 2),
                             'upper95': 2.19,
                             'upper99': 2.278},
                         tags=['stat'],
                         )
        assertEventEquals(self, expected, q[0])

        expected = Event(metric='rails.home.login.timings.view',
                         stats={
                             'count': 1,
                             'max': 2.0,
                             'mean': 2.0,
                             'median': 2.0,
                             'min': 2.0,
                             'rate': between(1, 100),
                             'stddev': 0.0,
                             'upper95': 2.0,
                             'upper99': 2.0},
                         tags=['stat'],
                         )
        assertEventEquals(self, expected, q[1])

        # wait for further two 'zero' stats
        q = self.wait(events=2)
Ejemplo n.º 6
0
    def test_wildcard(self):
        self.create(
            {
                'period': 0.1,
                'metrics': {
                    'rails.{controller}.{action}.{0}': '*'
                }
            }, self.events)

        # 8 events expected - the above 6, and then 4 stat events
        q = self.wait(events=10)

        q = [i for i in q if i.stats]
        q.sort(key=lambda k: k.metric)

        expected = Event(
            metric='rails.home.index.bytes',
            stats={
                'count': 3,
                'rate': between(1, 100),
                'max': 30159,
                'min': 6926,
                'median': 18150,
                'mean': 18411,
                'stddev': about(30789),
                'upper95': 28958.1,
                'upper99': 29918.82,
            },
            tags=['stat'],
        )
        assertEventEquals(self, expected, q[0])

        expected = Event(
            metric='rails.home.index.duration',
            stats={
                'count': 3,
                'rate': between(1, 100),
                'max': 4.0,
                'min': 3.0,
                'median': 3.5,
                'mean': 3.5,
                'stddev': 5.0,
                'upper95': 3.95,
                'upper99': 3.99,
            },
            tags=['stat'],
        )
        assertEventEquals(self, expected, q[1])

        expected = Event(
            metric='rails.home.login.duration',
            stats={
                'count': 1,
                'rate': between(1, 100),
                'max': 2.4,
                'min': 2.4,
                'median': 2.4,
                'mean': 2.4,
                'stddev': 0.0,
                'upper95': 2.4,
                'upper99': 2.4,
            },
            tags=['stat'],
        )
        assertEventEquals(self, expected, q[3])