Skip to main content

A profiler for Python and mongodb

Project description


A Python mongodb monitor and profiler for development.

Quick Start

Install using pip/pipenv/etc. (we recommend poetry for sane dependency management):

$ poetry add mongomon --dev

Initialize before you set up your MongoDB connection:

from mongomon import Monitor, Config

Use file_capture to specify how to extract relevant project file paths from traces, rather than absolute file paths.

Exploring the Example

We've taken the example from Flask-PyMongo to show how easy it is to have mongomon integrated and running.

You can look at the integration here. To run it:

$ poetry shell
$ cd examples/wiki && pip install -r requirements
$ python


Your main configuration points for mongomon are:

  • file_capture - an aesthetic configuration point for capturing files for your project. Usually of the form .*/(your-project.*), content in parenthesis are a regular expression capture group, and is what we actually extract.
  • low_watermark_us - a threshold in microseconds (us) above which mongomon starts working (yellow).
  • high_watermark_us - a high threshold in microseconds (us) above which mongomon displays timing as alert (red).

Rest of configuration looks like so (with their defaults and comments):

    # cleans up stack trace with uninteresting things. Usually packages, standard library, etc.
    ignores = attrib(
    # shows a file, cleans up absolute path to a file
    file_capture = attrib(default="(.*)")
    # above this value mongomon starts working
    low_watermark_us = attrib(default=5000)
    # above this value mongomon flags as alert
    high_watermark_us = attrib(default=40000)
    # customize how mongodb query looks like before printing to screen
    query_filter = attrib(default=identity)
    # want to print to something else? replace this
    print_fn = attrib(default=print_)
    # want shorter stack traces? customize this
    stack_preprocess = attrib(default=trim_last)


To all Contributors - you make this happen, thanks!


Copyright (c) 2019 @jondot. See LICENSE for further details.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mongomon, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size mongomon-0.0.5.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View
Filename, size mongomon-0.0.5-py2.py3-none-any.whl (4.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page