Ejemplo n.º 1
0
    def test_15_callback_multi_guage(self, g):
        _reset()
        configs = {
            'name': 'cool3',
            'tags': ['list:strings'],
            'metrics': {
                'counters': [('message', 'dd.key')],
                'gauges': [(
                    "some log",
                    [
                        ("some_log_gauge1", "key.key2"),
                        ("some_log_gauge2", "key.value"),  # doesnt exist, ok
                        ("some_log_gauge3", "key3"),
                    ])],
            },
            'options': {
                'statsd_host': 'localhost',
                'statsd_port': 8125,
                'local': True,
            }
        }
        dw_config(configs)

        extras = {'key': {'key2': 41}, 'key3': 55}
        dw_callback("some log", extras)

        calls = [
            call('cool3.some_log_gauge1', 41, tags=['list:strings']),
            call('cool3.some_log_gauge3', 55, tags=['list:strings']),
        ]
        g.assert_has_calls(calls)
Ejemplo n.º 2
0
 def test_07_config_bad_dd(self):
     _reset()
     # assert no api key
     configs = {'name': 'cool'}
     with self.assertRaises(Exception) as e:
         dw_config(configs)
     self.assertEquals(e.exception.args[0],
                       "Unknown statsd config for DataDog setup")
Ejemplo n.º 3
0
 def test_08_config_dd(self):
     _reset()
     configs = {
         'name': 'cool',
         'options': {
             'statsd_host': 'localhost',
             'statsd_port': 8125,
         }
     }
     dw_config(configs)
Ejemplo n.º 4
0
    def test_14_not_init(self, i):
        _reset()
        configs = {
            'name': 'cool3',
            'options': {
                'statsd_host': 'localhost',
                'statsd_port': 8125,
                'local': True,
            }
        }
        dw_callback("message", {})

        i.assert_not_called()
Ejemplo n.º 5
0
    def test_13_callback_counter(self, i):
        _reset()
        configs = {
            'name': 'cool3',
            'options': {
                'statsd_host': 'localhost',
                'statsd_port': 8125,
                'local': True,
            }
        }
        dw_config(configs)

        dw_callback("message", {})

        i.assert_called_once_with('cool3.message', tags=[])
Ejemplo n.º 6
0
 def test_19_case_insensitive_tags_increment(self):
     _reset()
     configs = {
         'name': 'cool3',
         'tags': ['lIsT:stRinGs'],
         'options': {
             'statsd_host': 'localhost',
             'statsd_port': 8125,
             'local': False,  # Force sending tags
         }
     }
     dw_config(configs)
     with patch.object(_get_dw_stats(), 'increment') as statsd_increment:
         dw_callback("message", {})
         statsd_increment.assert_called_once_with(metric='cool3.message',
                                                  tags=['list:strings'])
Ejemplo n.º 7
0
    def test_12_callback_counter_mapping(self, i):
        _reset()
        configs = {
            'name': 'cool2',
            'tags': ['list:strings'],
            'metrics': {
                'counters': [('message', 'dd.key')],
                'gauges': [
                    ("some log", "some_log", "key.key2.crazy"),
                ],
            },
            'options': {
                'statsd_host': 'localhost',
                'statsd_port': 8125,
                'local': True,
            }
        }
        dw_config(configs)

        dw_callback("message", {})

        i.assert_called_once_with('cool2.dd.key', tags=['list:strings'])
Ejemplo n.º 8
0
    def test_11_callback_guage_no_val(self, g):
        _reset()
        configs = {
            'name': 'cool2',
            'tags': ['list:strings'],
            'metrics': {
                'counters': [('message', 'dd.key')],
                'gauges': [
                    ("some log", "some_log", "key.key2.crazy"),
                ],
            },
            'options': {
                'statsd_host': 'localhost',
                'statsd_port': 8125,
                'local': True,
            }
        }
        dw_config(configs)

        extras = {'key': {'key2': 41}}
        dw_callback("some log", extras)

        g.assert_not_called()
Ejemplo n.º 9
0
 def test_18_case_insensitive_tags_guage(self):
     _reset()
     configs = {
         'name': 'cool2',
         'tags': ['lIsT:stRinGs'],
         'metrics': {
             'counters': [('message', 'dd.key')],
             'gauges': [
                 ("some log", "some_log", "key.key2"),
             ],
         },
         'options': {
             'statsd_host': 'localhost',
             'statsd_port': 8125,
             'local': False,  # Force sending tags
         }
     }
     dw_config(configs)
     with patch.object(_get_dw_stats(), 'gauge') as statsd_gauge:
         extras = {'key': {'key2': 41}}
         dw_callback("some log", extras)
         statsd_gauge.assert_called_once_with(metric='cool2.some_log',
                                              tags=['list:strings'],
                                              value=41)