Beispiel #1
0
    def test_gauge(self, capsys):
        ddcm = CloudwatchMetrics({})

        ddcm.gauge('foo', value=100, tags=['key1:val', 'key2:val'])
        out, err = capsys.readouterr()
        assert out == 'MONITORING|1488817800|100|gauge|foo|#key1:val,key2:val\n'
        assert err == ''
Beispiel #2
0
    def test_timing(self, capsys):
        # .timing is a histogram
        ddcm = CloudwatchMetrics({})

        ddcm.timing('foo', value=100, tags=['key1:val', 'key2:val'])
        out, err = capsys.readouterr()
        assert out == 'MONITORING|1488817800|100|histogram|foo|#key1:val,key2:val\n'
        assert err == ''
Beispiel #3
0
 def test_histogram(self, capsys):
     rec = MetricsRecord("histogram",
                         key="foo",
                         value=100,
                         tags=["key1:val", "key2:val"])
     ddcm = CloudwatchMetrics()
     ddcm.emit_to_backend(rec)
     out, err = capsys.readouterr()
     assert out == "MONITORING|1488817800|100|histogram|foo|#key1:val,key2:val\n"
     assert err == ""
Beispiel #4
0
    def test_filters(self, capsys):
        class BlueFilter(MetricsFilter):
            def filter(self, record):
                if "blue" not in record.key:
                    return
                return record

        ddcm = CloudwatchMetrics(filters=[BlueFilter()])
        ddcm.emit_to_backend(MetricsRecord("incr", key="foo", value=1,
                                           tags=[]))
        ddcm.emit_to_backend(
            MetricsRecord("incr", key="foo.blue", value=2, tags=[]))
        out, err = capsys.readouterr()
        assert out == "MONITORING|1488817800|2|count|foo.blue|\n"
        assert err == ""