Skip to main content

Build Status Coverage Status

mutornadomon

µtornadomon is a library designed to be used with Tornado web applications. It adds an endpoint (/mutornadomon) to HTTP servers which outputs application statistics for use with standard metric collectors.

Usage

The monitor is initialized using mutornadomon.config.initialize_mutornadomon.

Exposing an HTTP endpoint

If you only pass a tornado web application, it will include request/response statistics, and expose an HTTP endpoint for polling by external processes:

from mutornadomon.config import initialize_mutornadomon
import signal

[...]

application = tornado.web.Application(...)
monitor = initialize_mutornadomon(application)

def shut_down(*args):
    monitor.stop()
    some_other_application_stop_function()
    tornado.ioloop.IOLoop.current().stop()

for sig in (signal.SIGQUIT, signal.SIGINT, signal.SIGTERM):
    signal.signal(sig, shut_down)

This will add a /mutornadomon endpoint to the web application.

Here is an example request to that endpoint:

$ curl http://localhost:8080/mutornadomon
{"process": {"uptime": 38.98995113372803, "num_fds": 8, "meminfo": {"rss_bytes": 14020608, "vsz_bytes": 2530562048}, "cpu": {"num_threads": 1, "system_time": 0.049356776, "user_time": 0.182635456}}, "max_gauges": {"ioloop_pending_callbacks": 0, "ioloop_handlers": 2, "ioloop_excess_callback_latency": 0.0006290912628173773}, "min_gauges": {"ioloop_pending_callbacks": 0, "ioloop_handlers": 2, "ioloop_excess_callback_latency": -0.004179096221923834}, "gauges": {"ioloop_pending_callbacks": 0, "ioloop_handlers": 2, "ioloop_excess_callback_latency": 0.0006290912628173773}, "counters": {"callbacks": 388, "requests": 6, "localhost_requests": 6, "private_requests": 6}}

If you want to add your own metrics, you can do so by calling the .kv() or .count() methods on the monitor object at any time.

The HTTP endpoint is restricted to only respond to request from loopback.

Providing a publishing callback

Alternatively, instead of polling the HTTP interface, you can pass in a publisher callback:

import pprint

def publisher(metrics):
    pprint.pprint(metrics)

monitor = initialize_mutornadomon(application, publisher=publisher)

By default, this will call the publisher callback every 10 seconds. To override this pass the publish_interval parameter (in miliseconds).

Monitoring non-web applications

If you don't pass an application object, other stats can still be collected:

import pprint

def publisher(metrics):
    pprint.pprint(metrics)

monitor = initialize_mutornadomon(publisher=publisher)

This only works with the publisher callback interface.

Metadata

Release files for mutornadomon 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mutornadomon 0.5.1
File Size Uploaded Provenance Actions
mutornadomon-0.5.1.tar.gz 9.2 kB Without provenance Details for mutornadomon-0.5.1.tar.gz

Release files / mutornadomon-0.5.1.tar.gz

Download URL mutornadomon-0.5.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
442b24178924a510525e25bc17d2222e849ee4fbe6edc592b631173103e7fa19
BLAKE2b-256 checksum
How to use checksums
c8f37e2f6ffe00344faa9744f9e7aefc19a8f3633e39a3baecb70b60e1ca3983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.4.10

Security for mutornadomon 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page