Skip to main content

pachifast-metrics

Prometheus metrics for pachifast (source) projects: an extension package. It adds a GET /metrics endpoint and a middleware that counts and times every request.

Status: alpha. It follows pachifast 0.x: the minor versions of this package may break, and each release works with one minor of pachifast (requires_pachifast).

Install

uv add pachifast-metrics

Then list the module in the project_modules.py of your project (see extending pachifast):

from pachifast.presets import core_module
from pachifast_metrics import module as metrics_module

MODULES = (core_module, metrics_module, ...)

What it exposes

GET /metrics (at the root, not under /api), in the Prometheus text format:

Metric Type Labels
pachifast_http_requests_total counter method, route, status
pachifast_http_request_duration_seconds histogram method, route
pachifast_http_requests_in_progress gauge

route is the route template (/api/users/{user_id}), never the path with the real id, and a request that matches no route is unmatched: the number of series stays bounded whatever the clients send. The scrape of /metrics is not counted.

Settings

Environment variables, read when the endpoint is called:

Variable Default Effect
PACHIFAST_METRICS_TOKEN empty When set, /metrics answers only to Authorization: Bearer <token> (401 otherwise). Empty: open, so keep it off the public internet (a reverse proxy rule, or a network that only Prometheus reaches).
PACHIFAST_METRICS_ENABLED true false makes /metrics answer 404.

Prometheus:

scrape_configs:
  - job_name: myproject
    authorization:
      credentials: <the token>
    static_configs:
      - targets: ["myproject:8000"]

With several workers each process keeps its own counters: scrape every worker (one per port or pod), or put prometheus_client's multiprocess mode behind your server; this package does not do it for you.

Develop

uv sync
uv run pytest -q
uv run ruff check . && uv run ruff format --check .

License

MIT, see LICENSE.

Disclaimer. pachifast-metrics is provided "as is", without warranty of any kind. It is alpha software: it can contain bugs and change incompatibly between minor releases. You are responsible for reviewing, testing and securing the applications you build with it before using them in production.

Metadata

Release files for pachifast-metrics 0.1.2

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

Source distribution (sdist)

Source distribution for pachifast-metrics 0.1.2
File Size Uploaded Provenance Actions
pachifast_metrics-0.1.2.tar.gz 7.3 kB Without provenance Details for pachifast_metrics-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pachifast-metrics 0.1.2
File Interpreter ABI Platform Actions
pachifast_metrics-0.1.2-py3-none-any.whl Python 3 none any Details for pachifast_metrics-0.1.2-py3-none-any.whl

Total release size: 14.9 kB

Release files / pachifast_metrics-0.1.2.tar.gz

Download URL pachifast_metrics-0.1.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eda105e789fb80d60fb8891cbc124b955353ac22b886cd86359e2b6cd03a754e
BLAKE2b-256 checksum
How to use checksums
3918841fb76e3ff9ba1efd6865bec12c3d1dcb146be54ddf62ef6c36aaa62c65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pachifast_metrics-0.1.2-py3-none-any.whl

Download URL pachifast_metrics-0.1.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
290b74ad256ac0ffb7f5e54c60fcc6dc6b2275f990c0d87c93a52f723ee42a68
BLAKE2b-256 checksum
How to use checksums
50e34a4f40d3e834788f672d3dbc2099be8eec8a32c3b0906600ba1104d33480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pachifast-metrics 0.1.2

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