python和mongodb的探查器
mongomon的Python项目详细描述
蒙哥蒙
用于开发的PythonMongoDB监视器和探查器。
快速启动
使用pip/pipenv/etc进行安装(我们建议poetry用于SANE依赖关系管理):
$ poetry add mongomon --dev
在设置MongoDB连接之前初始化:
frommongomonimportMonitor,ConfigMonitor(Config(file_capture=".*/(wiki.*)")).monitor()
使用file_capture
指定如何从跟踪中提取相关的项目文件路径,而不是绝对文件路径。
探索示例
我们以Flask-PyMongo中的例子来说明如何轻松地集成和运行mongomon。
你可以look at the integration here。运行它:
$ poetry shell
$ cd examples/wiki && pip install -r requirements
$ python wiki.py
配置
Mongomon的主要配置点是:
file_capture
-一个用于捕获项目文件的美观配置点。通常是.*/(your-project.*)
形式,括号中的内容是正则表达式捕获组,是我们实际提取的内容。low_watermark_us
-以微秒为单位的阈值(US),高于此阈值,Mongomon开始工作(黄色)。high_watermark_us
-一个以微秒为单位的高阈值(US),超过此阈值,Mongomon将计时显示为警报(红色)。
其余配置看起来是这样的(带有默认值和注释):
# cleans up stack trace with uninteresting things. Usually packages, standard library, etc.ignores=attrib(default=[".*/site-packages/.*",".*traceback.format_stack.*",r".*/lib/python\d\.\d+/.*",])# shows a file, cleans up absolute path to a filefile_capture=attrib(default="(.*)")# above this value mongomon starts workinglow_watermark_us=attrib(default=5000)# above this value mongomon flags as alerthigh_watermark_us=attrib(default=40000)# customize how mongodb query looks like before printing to screenquery_filter=attrib(default=identity)# want to print to something else? replace thisprint_fn=attrib(default=print_)# want shorter stack traces? customize thisstack_preprocess=attrib(default=trim_last)
谢谢:
对所有人来说-你做到了,谢谢!
版权所有
版权所有(c)2019@jondot。有关详细信息,请参见LICENSE。