示例#1
0
async def test_client_event(event_loop):
    transport, protocol, port = await fake_server(event_loop)
    client = aiomeasures.Datadog('udp://127.0.0.1:%s' % port)
    client.event('title', 'text')
    await asyncio.sleep(.1)
    assert '_e{5,4}title|text' in protocol.msg
    transport.close()
    client.close()
示例#2
0
async def test_reliablility(event_loop):
    transport, protocol, port = await fake_server(event_loop)
    client = aiomeasures.Datadog('udp://127.0.0.1:%s' % port)
    client.incr('example.a')
    await asyncio.sleep(.1)
    assert 'example.a:1|c' in protocol.msg
    transport.close()

    client.incr('example.b')
    await asyncio.sleep(.1)
    assert 'example.b:1|c' not in protocol.msg

    transport, protocol, port = await fake_server(event_loop, port)
    client.incr('example.c')
    await asyncio.sleep(.1)
    assert 'example.c:1|c' in protocol.msg
    transport.close()

    client.close()
示例#3
0
async def test_client(event_loop):
    transport, protocol, port = await fake_server(event_loop)
    client = aiomeasures.Datadog('udp://127.0.0.1:%s' % port)
    client.incr('example.a')
    client.timing('example.b', 500)
    client.gauge('example.c', 1)
    client.set('example.d', 'bar')
    client.decr('example.e')
    client.counter('example.f', 42)
    client.histogram('example.g', 13)
    await asyncio.sleep(.1)
    assert 'example.a:1|c' in protocol.msg
    assert 'example.b:500|ms' in protocol.msg
    assert 'example.c:1|g' in protocol.msg
    assert 'example.d:bar|s' in protocol.msg
    assert 'example.e:-1|c' in protocol.msg
    assert 'example.f:42|c' in protocol.msg
    assert 'example.g:13|h' in protocol.msg
    transport.close()
    client.close()
示例#4
0
def test_formatting(metric, expected):
    handler = aiomeasures.Datadog(':0')
    assert handler.format(metric) == expected
示例#5
0
def test_checks(check, expected):
    handler = aiomeasures.Datadog(':0')
    assert handler.format(check) == expected
示例#6
0
    def __init__(self, dd_agent_url=None):
        self.dd_agent_url = dd_agent_url
        self.agent = None

        if dd_agent_url:
            self.agent = aiomeasures.Datadog(dd_agent_url)