Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmonroy/aiometrics
Generate metrics from AsyncIO applications
https://github.com/dmonroy/aiometrics
asyncio metrics newrelic
Last synced: 2 months ago
JSON representation
Generate metrics from AsyncIO applications
- Host: GitHub
- URL: https://github.com/dmonroy/aiometrics
- Owner: dmonroy
- License: mit
- Created: 2016-06-19T04:12:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-09T17:08:54.000Z (almost 8 years ago)
- Last Synced: 2024-11-09T00:13:28.394Z (3 months ago)
- Topics: asyncio, metrics, newrelic
- Language: Python
- Size: 7.81 KB
- Stars: 16
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - aiometrics - Generate metrics from AsyncIO applications (Python)
README
# 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 randomimport 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 (per minute):
- Total number of executions
- Minimum execution time
- Maximum execution time
- Average execution time