def setUp(self):
     self.application = None
     super(StatsdMetricCollectionTests, self).setUp()
     self.statsd = FakeStatsdServer(self.io_loop)
     statsd.install(
         self.application, **{
             'namespace': 'testing',
             'host': self.statsd.sockaddr[0],
             'port': self.statsd.sockaddr[1],
             'prepend_metric_type': True
         })
def make_application():
    """
    Create a application configured to send metrics.

    Metrics will be sent to localhost:8125 namespaced with
    ``webapps``. Run netcat or a similar listener then run this
    example. HTTP GETs will result in a metric like::

        webapps.SimpleHandler.GET.204:255.24497032165527|ms

    """
    settings = {}
    application = web.Application([web.url('/', SimpleHandler)], **settings)
    statsd.install(application, **{'namespace': 'testing'})
    return application
    def setUp(self):
        self.application = None
        self.namespace = 'testing'

        super().setUp()
        self.statsd = FakeStatsdServer(self.io_loop, protocol='tcp')

        statsd.install(
            self.application, **{
                'namespace': self.namespace,
                'host': self.statsd.sockaddr[0],
                'port': self.statsd.sockaddr[1],
                'protocol': 'tcp',
                'prepend_metric_type': True
            })
 def test_default_host_and_port_is_used(self):
     statsd.install(self.application, **{'namespace': 'testing'})
     self.assertEqual(self.application.statsd._host, '127.0.0.1')
     self.assertEqual(self.application.statsd._port, 8125)
 def test_port_is_used(self):
     statsd.install(self.application, **{'port': '8888'})
     self.assertEqual(self.application.statsd._port, 8888)
 def test_host_is_used(self):
     statsd.install(self.application, **{'host': 'example.com'})
     self.assertEqual(self.application.statsd._host, 'example.com')
 def test_collecter_is_not_reinstalled(self):
     self.assertTrue(statsd.install(self.application))
     self.assertFalse(statsd.install(self.application))