def test_namespace(self, aggregator):
        check = AgentCheck()
        check.__NAMESPACE__ = 'test'

        check.service_check('service_check', AgentCheck.OK)
        aggregator.assert_service_check('test.service_check',
                                        status=AgentCheck.OK)
    def test_namespace(self, aggregator):
        check = AgentCheck()
        check.__NAMESPACE__ = 'test'

        check.gauge('metric', 0)

        aggregator.assert_metric('test.metric')
    def test_namespace_override(self, aggregator):
        check = AgentCheck()
        check.__NAMESPACE__ = 'test'

        methods = ('gauge', 'count', 'monotonic_count', 'rate', 'histogram', 'historate', 'increment', 'decrement')
        for method in methods:
            getattr(check, method)('metric', 0, raw=True)

        aggregator.assert_metric('metric', count=len(methods))
 def test_namespace(self, aggregator):
     check = AgentCheck()
     check.__NAMESPACE__ = 'test'
     event = {
         'event_type': 'new.event',
         'msg_title': 'new test event',
         'aggregation_key': 'test.event',
         'msg_text': 'test event test event',
         'tags': None,
     }
     check.event(event)
     aggregator.assert_event('test event test event', source_type_name='test')
Beispiel #5
0
    def test_metrics_filters(self, exclude_metrics_filters, include_metrics_filters, expected_metrics, aggregator):
        instance = {
            'metric_patterns': {
                'exclude': exclude_metrics_filters,
                'include': include_metrics_filters,
            }
        }
        check = AgentCheck('myintegration', {}, [instance])
        check.__NAMESPACE__ = 'ns'
        check.gauge('my_metric', 0)
        check.count('my_metric_count', 0)
        check.count('test.my_metric1', 1)
        check.monotonic_count('hello', 0)
        check.service_check('test.can_check', status=AgentCheck.OK)

        for metric_name in expected_metrics:
            aggregator.assert_metric('ns.{}'.format(metric_name), count=1)

        aggregator.assert_service_check('ns.test.can_check', status=AgentCheck.OK)
        aggregator.assert_all_metrics_covered()