Skip to main content

Minimalist SRE metrics for FastAPI and Flask

Project description

SRE Metrics

PyPI

Minimalist SRE metrics for Python web frameworks.

Features

  • Default metrics on port 9090
  • Tracks individual status codes + optional grouping
  • FastAPI and Flask support
  • <5ms overhead

FastAPI Installation

pip install sre_metrics[fastapi]

FastAPI Usage

from fastapi import FastAPI
from sre_metrics import instrument_fastapi

app = FastAPI()
instrument_fastapi(app)  # Metrics on :9090 by default

# Custom port
instrument_fastapi(app, metrics_port=9091, excluded_paths=["/healthz"])

Flask Installation

pip install sre_metrics[flask]
from flask import Flask
from sre_metrics import instrument_flask

app = Flask(__name__)
instrument_flask(app)  # Metrics on :9090

# Custom options:
instrument_flask(app, metrics_port=9091, excluded_paths=["/healthz"])

Rebuild locally

uv sync
uv pip install twine fastapi flask httpx uvicorn requests
uv run pytest
rm -rf build/ dist/ sre_metrics.egg-info/
uv run python -m build
pip install --force-reinstall dist/sre_metrics-*-py3-none-any.whl
python -c "import sre_metrics;"

## twine
uv add twine
rm -rf build/ dist/ sre_metrics.egg-info/
uv run python -m build
pip install --force-reinstall dist/sre_metrics-*-py3-none-any.whl
twine upload dist/*

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

sre_metrics-1.0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

sre_metrics-1.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file sre_metrics-1.0.4.tar.gz.

File metadata

  • Download URL: sre_metrics-1.0.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for sre_metrics-1.0.4.tar.gz
Algorithm Hash digest
SHA256 4dbb18332b63c218d37b9dd6692e253da6228eabca79ff8a6bd347c14378b8b8
MD5 54038e6da6b9f4fe706dbd329895a97e
BLAKE2b-256 4df5dbe032ae47267f4f863786b5c938acae8615492dbf48394744cd2f977afc

See more details on using hashes here.

File details

Details for the file sre_metrics-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: sre_metrics-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for sre_metrics-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2c26385a27e6091a8249dd5b4ecfc5f96c045488d975a06b26f0f8869bc78bf
MD5 d03c6bd09b041a32a4ff5091fe9b45d9
BLAKE2b-256 357a54635aa56c673a9a5643324dc2311e3c4eee8b27dc12f9b3d7f5318d4eb2

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