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.4

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.4
File Size Uploaded Provenance Actions
pachifast_metrics-0.1.4.tar.gz 7.4 kB Without provenance Details for pachifast_metrics-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 14.9 kB

Release files / pachifast_metrics-0.1.4.tar.gz

Download URL pachifast_metrics-0.1.4.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8a6553dfc37e63e82866ca3f004924cc2ba8e6cc39089cee3a3839e855ec33b8
BLAKE2b-256 checksum
How to use checksums
566075239aa745ea3ad89c6acbee64b18f12da8ca014af1f05ace4a9a2fc888d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","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.4-py3-none-any.whl

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

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