向riemann发送计时和异常统计信息
riemann_wrapper的Python项目详细描述
介绍性博客文章:http://www.spootnik.org/entries/2013/05/21_using-riemann-to-monitor-python-apps.html
提供此库是为了允许定时和异常报告 使用http://riemann.io的python函数。
安装
管道:
pip install riemann_wrapper
PYPI:https://pypi.python.org/pypi/riemann_wrapper
手册:
python setup.py install
用法
提供度量名称和用于计时的bernhard客户端:
import bernhard from riemann_wrapper import wrap_riemann, riemann_wrapper riemann = bernhard.Client() @wrap_riemann("cpu-intensive-task", client=riemann) def do_something_cpu_intensive(): # [...]
看涨期权:
以下关键字参数可以传递给wrap_riemann:
- client:用 发送事件的bernhard.Client实例
- tags:附加到riemann事件的标记
- host:重写事件的主机名
- logger:一个标准的python记录器,可以记录传输错误
或者,可以通过调用 riemann_wrapper喜欢这样:
import bernhard from riemann_wrapper import wrap_riemann, riemann_wrapper riemann = bernhard.Client() my_wrapper = riemann_wrapper(client=bernhard.Client(), prefix="myapp.") @my_wrapper("cpu-intensive-task") def do_something_cpu_intensive(): # [...]
以下关键字参数可以传递给riemann_wrapper:
- client:用 发送事件的bernhard.Client实例
- global_tags:所有已发送事件中都存在标记。默认值:['python']。
- host:覆盖所有事件的主机名。默认值:None。
- logger:一个标准的python记录器,可以记录传输错误。 默认值:None。
- prefix:为所有事件服务预先发送给定的字符串。默认值:python。
- exception_state:为异常发送的状态。默认值:'warning'。
- send_exceptions:接受异常作为 参数并返回一个布尔值以指定是否发送 里曼的例外。默认值:true。