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.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 pachifast-metrics 0.1.1
File Size Uploaded Provenance Actions
pachifast_metrics-0.1.1.tar.gz 7.3 kB Without provenance Details for pachifast_metrics-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 14.8 kB

Release files / pachifast_metrics-0.1.1.tar.gz

Download URL pachifast_metrics-0.1.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
93f8acbf83e441a4cc51d6c9f214b93ffe2645d3345ce1a6cb53738ea962ebb6
BLAKE2b-256 checksum
How to use checksums
6af89ab1691d33eb6af525998f72c08316e5701e179061219590fe3319a94d11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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.1-py3-none-any.whl

Download URL pachifast_metrics-0.1.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4730a606530580117d750cf069a4824e8a717d4a5f9250cb3a68e9cd52efa2fb
BLAKE2b-256 checksum
How to use checksums
6dc6348c60bea74b6f45edb94b93c6824ce3f21e3123f9a330481af06e853786
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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.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