Skip to main content

Drop-in ASGI/WSGI middleware for endpoint timing

Project description

philiprehberger-api-timer

Drop-in ASGI/WSGI middleware for endpoint timing with Server-Timing headers.

Installation

pip install philiprehberger-api-timer

Usage

ASGI (FastAPI, Starlette)

from fastapi import FastAPI
from philiprehberger_api_timer import ASGITimerMiddleware

app = FastAPI()
app.add_middleware(ASGITimerMiddleware, slow_threshold_ms=500)

WSGI (Flask, Django)

from flask import Flask
from philiprehberger_api_timer import WSGITimerMiddleware

app = Flask(__name__)
app.wsgi_app = WSGITimerMiddleware(app.wsgi_app, slow_threshold_ms=500)

What It Does

  • Adds Server-Timing header to every response (e.g., Server-Timing: total;dur=42.5)
  • Logs a WARNING for requests exceeding the slow threshold
  • Zero configuration required — just add the middleware

API

  • ASGITimerMiddleware(app, slow_threshold_ms=500) — ASGI middleware
  • WSGITimerMiddleware(app, slow_threshold_ms=500) — WSGI middleware

License

MIT

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

philiprehberger_api_timer-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_api_timer-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_api_timer-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_api_timer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a6e2ec6a28d8d2c0d05b3d1b62686a497fd94f32604599c02f2396e5de073cec
MD5 057539b30cd4f1a50c5975b2a897d785
BLAKE2b-256 015c21225e8bf77453b35473ef2b04cc8da448417cc52803362520c6601b1a72

See more details on using hashes here.

File details

Details for the file philiprehberger_api_timer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_api_timer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2db31980bce9a17f25b307c9d0e2e51df5db50d0a2c379a5d76cea0ab8cd82ff
MD5 a2626cd8120b80cda8594fcdffefed9a
BLAKE2b-256 c97401dd3025ab5e1b63964694317bc5747ccded133ff45cca95c34a4fa91b22

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