File: timeit.py

package info (click to toggle)
aiodogstatsd 0.16.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: python: 1,080; makefile: 70; sh: 19
file content (22 lines) | stat: -rw-r--r-- 486 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import asyncio

import aiodogstatsd


async def main():
    client = aiodogstatsd.Client(
        host="0.0.0.0", port=9125, constant_tags={"whoami": "I am Batman!"}
    )
    await client.connect()

    # Use threshold_ms for setting a threshold for sending the timing metric.
    with client.timeit("fire"):
        # Do action we want to time
        pass

    await client.close()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())