[![ci](https://github.com/amenezes/async_metrics/workflows/ci/badge.svg)](https://github.com/amenezes/async_metrics/actions)
[![codecov](https://codecov.io/gh/amenezes/async_metrics/branch/main/graph/badge.svg?token=Y0J7INSN6Y)](https://codecov.io/gh/amenezes/async_metrics)
[![PyPI version](https://badge.fury.io/py/async_metrics.svg)](https://badge.fury.io/py/async_metrics)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/async_metrics)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# async_metrics
[asyncio](https://docs.python.org/3/library/asyncio.html) metrics for your app.
Available metrics:
- asyncio: event loop status, policy and exception handler and tasks info;
- system: uptime, platform, recursion limit, default encoding, phisical and virtual processors, system load and process user;
- dependencies: application dependencies;
- python: implementation, version and PATH;
- process: application process info like: threads, open files, connections, context switch and childrens PID;
- partitions: partitions usage;
- about: async_metrics version, project: url, issues and release pages.
![dashboard](docs/dashboard.png)
## Installation
Install and update using pip:
````bash
pip install -U async_metrics
````
## Usage
### AIOHTTP
```python
from aiohttp import web
from async_metrics.ext.aiohttp import setup_async_metrics
app = web.Application()
setup_async_metrics(app)
web.run_app(app, host="0.0.0.0")
```
### Flask
```python
from flask import Flask
from async_metrics.ext.flask import setup_async_metrics
app = Flask(__name__)
setup_async_metrics(app)
@app.route('/')
def hello_world():
return 'Hello, World!'
```
## Examples
Clone the repository, install the dependencies and follow the following steps:
### AIOHTTP
```bash
python examples/aiohttp_example.py
```
For web UI dashboard access:
- http://localhost:8080/async_metrics/dashboard
### Flask
```bash
FLASK_APP=examples/flask_example.py flask run
```
For web UI dashboard access:
- http://localhost:5000/async_metrics/dashboard
## CLI
### Installation
```bash
pip install async_metrics[cli]
```
### Usage
```bash
python -m async_metrics show -h
Usage: python -m async_metrics show [OPTIONS] [ADDRESS]
Options:
--asyncio Show summary information about async environmen.
--system Show information about system environment.
--deps Show applications dependencies.
--python Show information about current python environment.
--process Show summary information about application process.
--partitions Show summary information about disk partition.
--about Show information about async_metrics.
-h, --help Show this message and exit.
```
> **ADDRESS** can be set via environment variable `ASYNC_METRICS_HOST`
Acessing AIOHTTP example metrics:
```bash
# default request URL: http://localhost:8080/async_metrics
python -m async_metrics show --system
```
Acessing Flask example metrics:
```bash
python -m async_metrics show http://localhost:5000/async_metrics --system
```
## Links
- License: [Apache License](https://choosealicense.com/licenses/apache-2.0/)
- Code: [https://github.com/amenezes/async_metrics](https://github.com/amenezes/async_metrics)
- Issue tracker: [https://github.com/amenezes/async_metrics/issues](https://github.com/amenezes/async_metrics/issues)
- Docs: [https://github.com/amenezes/async_metrics](https://github.com/amenezes/async_metrics)
Raw data
{
"_id": null,
"home_page": "https://github.com/amenezes/async_metrics",
"name": "async-metrics",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "['asyncio','metrics']",
"author": "Alexandre Menezes",
"author_email": "alexandre.fmenezes@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d7/83/f91069573f8139a3d1141737b94e00d104d64074debc9f603d4727344e1d/async_metrics-0.1.0.tar.gz",
"platform": null,
"description": "[![ci](https://github.com/amenezes/async_metrics/workflows/ci/badge.svg)](https://github.com/amenezes/async_metrics/actions)\n[![codecov](https://codecov.io/gh/amenezes/async_metrics/branch/main/graph/badge.svg?token=Y0J7INSN6Y)](https://codecov.io/gh/amenezes/async_metrics)\n[![PyPI version](https://badge.fury.io/py/async_metrics.svg)](https://badge.fury.io/py/async_metrics)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/async_metrics)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# async_metrics\n\n[asyncio](https://docs.python.org/3/library/asyncio.html) metrics for your app.\n\nAvailable metrics:\n- asyncio: event loop status, policy and exception handler and tasks info;\n- system: uptime, platform, recursion limit, default encoding, phisical and virtual processors, system load and process user;\n- dependencies: application dependencies;\n- python: implementation, version and PATH;\n- process: application process info like: threads, open files, connections, context switch and childrens PID;\n- partitions: partitions usage;\n- about: async_metrics version, project: url, issues and release pages.\n\n![dashboard](docs/dashboard.png)\n\n## Installation\n\nInstall and update using pip:\n\n````bash\npip install -U async_metrics\n````\n\n## Usage\n\n### AIOHTTP\n\n```python\nfrom aiohttp import web\nfrom async_metrics.ext.aiohttp import setup_async_metrics\n\n\napp = web.Application()\nsetup_async_metrics(app)\n\nweb.run_app(app, host=\"0.0.0.0\")\n```\n\n### Flask\n\n```python\nfrom flask import Flask\nfrom async_metrics.ext.flask import setup_async_metrics\n\napp = Flask(__name__)\nsetup_async_metrics(app)\n\n@app.route('/')\ndef hello_world():\n return 'Hello, World!'\n```\n\n\n## Examples\n\nClone the repository, install the dependencies and follow the following steps:\n\n### AIOHTTP\n\n```bash\npython examples/aiohttp_example.py\n```\n\nFor web UI dashboard access:\n- http://localhost:8080/async_metrics/dashboard\n\n\n### Flask\n\n```bash\nFLASK_APP=examples/flask_example.py flask run\n```\n\nFor web UI dashboard access:\n- http://localhost:5000/async_metrics/dashboard\n\n\n## CLI\n\n### Installation\n\n```bash\npip install async_metrics[cli]\n```\n\n### Usage\n\n```bash\npython -m async_metrics show -h\nUsage: python -m async_metrics show [OPTIONS] [ADDRESS]\n\nOptions:\n --asyncio Show summary information about async environmen.\n --system Show information about system environment.\n --deps Show applications dependencies.\n --python Show information about current python environment.\n --process Show summary information about application process.\n --partitions Show summary information about disk partition.\n --about Show information about async_metrics.\n -h, --help Show this message and exit.\n```\n\n> **ADDRESS** can be set via environment variable `ASYNC_METRICS_HOST`\n\nAcessing AIOHTTP example metrics:\n\n```bash\n# default request URL: http://localhost:8080/async_metrics\npython -m async_metrics show --system\n```\n\nAcessing Flask example metrics:\n\n\n```bash\npython -m async_metrics show http://localhost:5000/async_metrics --system\n```\n\n## Links\n\n- License: [Apache License](https://choosealicense.com/licenses/apache-2.0/)\n- Code: [https://github.com/amenezes/async_metrics](https://github.com/amenezes/async_metrics)\n- Issue tracker: [https://github.com/amenezes/async_metrics/issues](https://github.com/amenezes/async_metrics/issues)\n- Docs: [https://github.com/amenezes/async_metrics](https://github.com/amenezes/async_metrics)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "simple metrics for your app",
"version": "0.1.0",
"split_keywords": [
"['asyncio'",
"'metrics']"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c783a0c557ad2317400f035c03d29f1f0dd33b38512d90bc74a82c3d0339f11d",
"md5": "5bf587b17d2b9089ba9c84974e8c376e",
"sha256": "f904fe4cbffd07f95e97500d271a93d822334ae4c8ddee09c060ae522cb82c91"
},
"downloads": -1,
"filename": "async_metrics-0.1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "5bf587b17d2b9089ba9c84974e8c376e",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.8",
"size": 19101,
"upload_time": "2023-03-16T02:54:34",
"upload_time_iso_8601": "2023-03-16T02:54:34.074303Z",
"url": "https://files.pythonhosted.org/packages/c7/83/a0c557ad2317400f035c03d29f1f0dd33b38512d90bc74a82c3d0339f11d/async_metrics-0.1.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d783f91069573f8139a3d1141737b94e00d104d64074debc9f603d4727344e1d",
"md5": "858c9f5fa934c4d89c6c3b2c3785f0f6",
"sha256": "32e422dbdce291cae518790cf8b8f183ecbc6d3a20877adc143369014e61d02e"
},
"downloads": -1,
"filename": "async_metrics-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "858c9f5fa934c4d89c6c3b2c3785f0f6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 17431,
"upload_time": "2023-03-16T02:54:36",
"upload_time_iso_8601": "2023-03-16T02:54:36.251321Z",
"url": "https://files.pythonhosted.org/packages/d7/83/f91069573f8139a3d1141737b94e00d104d64074debc9f603d4727344e1d/async_metrics-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-16 02:54:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "amenezes",
"github_project": "async_metrics",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "psutil",
"specs": []
},
{
"name": "aiohttp",
"specs": []
},
{
"name": "Flask",
"specs": []
},
{
"name": "rich",
"specs": []
},
{
"name": "click",
"specs": []
}
],
"lcname": "async-metrics"
}