Skip to main content

Instrument Tornado applications with Prometheus metrics.

Project description

Prometheus Tornado Instrumentator

A Tornado-focused Prometheus instrumentation library inspired by trallnag/prometheus-fastapi-instrumentator.

The goal is to provide a Tornado-native user experience:

from prometheus_tornado_instrumentator import Instrumentator

Instrumentator().instrument(app).expose(app)

Installation

From PyPI:

pip install prometheus-tornado-instrumentator

From a local checkout:

uv pip install -e .

Quick Start

from tornado.web import Application, RequestHandler

from prometheus_tornado_instrumentator import Instrumentator


class HelloHandler(RequestHandler):
    def get(self):
        self.write({"message": "hello"})


app = Application([(r"/hello", HelloHandler)])
Instrumentator().instrument(app).expose(app)

This instruments registered Tornado handlers and exposes Prometheus scrape output at /metrics by default.

Features

  • Default Prometheus metrics for request count, request size, response size, and latency.
  • Custom sync or async instrumentation functions.
  • Custom metric namespace and subsystem.
  • Custom Prometheus CollectorRegistry.
  • Gzip support for metrics output.
  • Regex-based handler exclusions.
  • Dynamic route instrumentation for handlers added with Application.add_handlers().
  • Prometheus client multiprocess support through PROMETHEUS_MULTIPROC_DIR.

Scope

This package instruments Tornado HTTP RequestHandler routes.

It does not provide FastAPI, Starlette, ASGI mounted-app, included-router, or websocket route semantics. See docs/parity.md for the upstream semantic-parity notes.

Documentation

Development

Use uv for local development:

uv sync --extra dev
uv run --extra dev python -m pytest -q

The current verified baseline is 105 passing tests.

License

This project is licensed under the ISC License. See LICENSE.

This project is inspired by trallnag/prometheus-fastapi-instrumentator, which is also licensed under the ISC License. See NOTICE for the initial upstream baseline.

Project details


Download files

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

Source Distribution

prometheus_tornado_instrumentator-0.1.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file prometheus_tornado_instrumentator-0.1.0.tar.gz.

File metadata

File hashes

Hashes for prometheus_tornado_instrumentator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4fb9a1b333bbd93b9e2ede739d29bbf332cf3107f923a94c41081997dea8d72d
MD5 e7f8f69ba5e3a04a072a75aa1fdcd743
BLAKE2b-256 4ca0f8b9605c0553ad096ceaa337532551cf42a5ad97f7462a1b79d77966f1fd

See more details on using hashes here.

File details

Details for the file prometheus_tornado_instrumentator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prometheus_tornado_instrumentator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89a541494a0465bc637d5b1a9253145ef11a1f1125d7449714ef73500a70cf4f
MD5 50ea64875c2f39e95205d8668b8609c4
BLAKE2b-256 2e869b71ea038cc9bd19d1cca67391307cf13482a4446cd9d2c46a1bfe78bd01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page