Metadata-Version: 2.4
Name: prometheus-tornado-instrumentator
Version: 0.1.2
Summary: Instrument Tornado applications with Prometheus metrics.
Author: JunwooZ
License-Expression: ISC
Project-URL: Homepage, https://github.com/JunwooZ/prometheus-tornado-instrumentator
Project-URL: Repository, https://github.com/JunwooZ/prometheus-tornado-instrumentator
Project-URL: Issues, https://github.com/JunwooZ/prometheus-tornado-instrumentator/issues
Keywords: prometheus,instrumentation,tornado,metrics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: prometheus-client<1.0,>=0.8
Requires-Dist: tornado<7.0,>=6.0
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Dynamic: license-file

# Prometheus Tornado Instrumentator

A Tornado-focused Prometheus instrumentation library inspired by
[`trallnag/prometheus-fastapi-instrumentator`](https://github.com/trallnag/prometheus-fastapi-instrumentator).

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

```python
from prometheus_tornado_instrumentator import Instrumentator

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

## Installation

From PyPI:

```bash
pip install prometheus-tornado-instrumentator
```

From a local checkout:

```bash
uv pip install -e .
```

## Quick Start

```python
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](docs/parity.md) for the upstream
semantic-parity notes.

## Documentation

- [Usage](docs/usage.md)
- [API reference](docs/api.md)
- [Development](docs/development.md)
- [Release process](docs/release.md)
- [Upstream parity](docs/parity.md)
- [Documentation index](docs/README.md)

## Development

Use `uv` for local development:

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

## License

This project is licensed under the ISC License. See [LICENSE](LICENSE).

This project is inspired by
[`trallnag/prometheus-fastapi-instrumentator`](https://github.com/trallnag/prometheus-fastapi-instrumentator),
which is also licensed under the ISC License. See [NOTICE](NOTICE) for the
initial upstream baseline.
