Generate metrics from AsyncIO applications
Project description
# aiometrics
Generate metrics from asyncio applications
## How to install
As any other python package, use pip or include it in the `install_requires` section of your setup.py
```
pip install aiometrics
```
## Sample
Sample application included below makes usage of the default StdoutDriver to print the metrics into the stdout.
```
# sample.py
import asyncio
import datetime
import random
import aiometrics
@aiometrics.trace
@asyncio.coroutine
def echo_delay():
ms = random.randrange(0, 5000)
t = ms/1000
yield from asyncio.sleep(t)
print(datetime.datetime.now())
@asyncio.coroutine
def main():
while True:
yield from echo_delay()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
```
Run this sample with the following command:
```python sample.py```
Here is the sample output:
```
2016-06-20 17:56:03.969607
...
2016-06-20 17:57:03.993648
{"instance": {"hostname": "dmo.local", "id": "acf9842e-c127-4844-8026-d7c518076ac2"}, "traces": {"__main__:echo_delay": {"2016-06-20T23:56:00+00": {"count": 24, "avg": 2510.3998333333334, "min": 229.113, "max": 4986.661}}}}
```
This generates a _per-minute_ report listing metrics for every coroutine function decorated with `@aiometrics.trace`. Metrics include:
- Total number of executions
- Minimum execution time
- Maximum execution time
- Average execution time
Generate metrics from asyncio applications
## How to install
As any other python package, use pip or include it in the `install_requires` section of your setup.py
```
pip install aiometrics
```
## Sample
Sample application included below makes usage of the default StdoutDriver to print the metrics into the stdout.
```
# sample.py
import asyncio
import datetime
import random
import aiometrics
@aiometrics.trace
@asyncio.coroutine
def echo_delay():
ms = random.randrange(0, 5000)
t = ms/1000
yield from asyncio.sleep(t)
print(datetime.datetime.now())
@asyncio.coroutine
def main():
while True:
yield from echo_delay()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
```
Run this sample with the following command:
```python sample.py```
Here is the sample output:
```
2016-06-20 17:56:03.969607
...
2016-06-20 17:57:03.993648
{"instance": {"hostname": "dmo.local", "id": "acf9842e-c127-4844-8026-d7c518076ac2"}, "traces": {"__main__:echo_delay": {"2016-06-20T23:56:00+00": {"count": 24, "avg": 2510.3998333333334, "min": 229.113, "max": 4986.661}}}}
```
This generates a _per-minute_ report listing metrics for every coroutine function decorated with `@aiometrics.trace`. Metrics include:
- Total number of executions
- Minimum execution time
- Maximum execution time
- Average execution time
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiometrics-0.1.2.tar.gz
(3.9 kB
view details)
File details
Details for the file aiometrics-0.1.2.tar.gz
.
File metadata
- Download URL: aiometrics-0.1.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdb1ce0044d9f9cb6f0d4fec5b2a5f9008b16a5029cb1524e9c0a821e5a7b88b |
|
MD5 | 1778528631aac1cdd63bebb8da480ab6 |
|
BLAKE2b-256 | ff677498e55215b944fd147bfd74bd129c38a1f4979d321ba41f18f0417acf7e |