Esempio n. 1
0
    def test_metric_limit_instance_config_zero_unlimited(self, aggregator):
        instances = [{"max_returned_metrics": 0}]
        check = AgentCheck("test", {}, instances)
        assert len(check.get_warnings()) == 0

        for _ in range(0, 42):
            check.gauge("metric", 0)
        assert len(check.get_warnings()) == 0  # get_warnings resets the array
        assert len(aggregator.metrics("metric")) == 42
    def test_metric_limit_instance_config(self, aggregator):
        instances = [{"max_returned_metrics": 42}]
        check = AgentCheck("test", {}, instances)
        assert check.get_warnings() == []

        for _ in range(0, 42):
            check.gauge("metric", 0)
        assert len(check.get_warnings()) == 0
        assert len(aggregator.metrics("metric")) == 42

        check.gauge("metric", 0)
        assert len(check.get_warnings()) == 1
        assert len(aggregator.metrics("metric")) == 42