Python的多功能指标收集库
项目描述
PyMetrics 是一个多功能的Python指标收集库,它将计数器、仪表、直方图和计时器封装到一个通用接口中,并具有可插拔的发布者,以便您可以在不遭受供应商锁定的情况下帮助性地监控应用程序。
发布指标是一个简单的两个步骤的过程。首先,配置您的指标和发布者
METRICS_CONFIG = {
'version': 2,
'error_logger_name': 'pymetrics',
'publishers': [
{
'path': 'pymetrics.publishers.datadog.DogStatsdPublisher',
'kwargs': {
'host': 'localhost',
'port': 8135,
},
},
],
}
然后,在您的应用程序中使用 pymetrics.recorders.base.MetricsRecorder 来收集和发布
from pymetrics.recorders.default import DefaultMetricsRecorder
metrics = DefaultMetricsRecorder(config=settings.METRICS_CONFIG)
metrics.counter('counter.name').increment()
metrics.gauge('gauge.name', tag_name1='tag_value1', tag_name2='tag_value2').set(12)
metrics.histogram('histogram.name').set(1730)
with metrics.timer('timer.name'):
do_something()
cumulative_timer = metrics.timer('cumulative_timer.name')
for item in items:
do_something_without_timing()
with cumulative_timer:
do_something_with_timing()
metrics.publish_all()
提供的发布者插件包括Statsd、Datadog、Python日志记录、SQLite和null发布者。编写自己的插件很简单,我们鼓励您通过提交拉取请求的方式与社区分享您的工作。
许可证
PyMetrics遵循Apache许可证,版本2.0。
安装
PyMetrics可在PyPI上找到,可以通过Pip直接安装,或在setup.py、requirements.txt或Pipfile中列出。
pip install 'pymetrics~=1.0'
install_requires=[
...
'pymetrics~=1.0',
...
]
pymetrics~=1.0
pymetrics = {version="~=1.0"}
文档
PyMetrics的完整文档可在Read the Docs上找到!
项目详情
关闭
哈希值 for pymetrics-1.0.10-py27.py35.py36.py37.py38-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ef2b1eae7b7711d352864e10b9a786f07f3dcada1fef7d4a7fcc30a9aa7e0407 |
|
MD5 | 496c74648c85b12b1fcce364ed405f6b |
|
BLAKE2b-256 | c6db54cfc87868cb495105664886ba84163ddcb90e8a705b6603f6a472a960d2 |