timing-asgi
ASGI middleware to emit timing metrics with something like statsd
What it is and what it does
Timing-asgi is a middleware layer for ASGI applications that automatically captures timing data for each request as it passes through your application. It measures both wall-clock time and CPU time, then emits these metrics along with HTTP context (status code, method) to a pluggable client interface. The middleware was built at GRID for use with Starlette-based backend services and is designed to feed metrics into statsd-compatible monitoring systems like Datadog.
You integrate it by wrapping your ASGI app with the TimingMiddleware, providing a TimingClient implementation (which can print, send to Datadog, or route metrics anywhere else) and a metric namer that converts ASGI scope information into readable metric names. The middleware handles the instrumentation transparently; your application code remains unchanged.
Use it for:
- Emit per-endpoint wall-clock and CPU timing to Datadog or another statsd service for production monitoring.
- Automatically track HTTP request latency by status code and method without modifying route handlers.
- Build a custom metrics client to route timing data to your own monitoring or logging backend.
- Profile ASGI application performance in development by printing timing metrics to stdout or a log file.
- Measure CPU vs. wall-clock time to identify I/O-bound vs. compute-bound bottlenecks in endpoints.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Timing-asgi is an ASGI middleware that automatically measures and emits endpoint timing metrics (wall-clock and CPU time) with HTTP context tags, designed for integration with statsd-based monitoring services.
Yes, if you need automatic ASGI endpoint timing instrumentation and your license requirements can tolerate an unclear license status. The package is actively maintained, has no dependencies, and integrates cleanly with Starlette and other ASGI frameworks. Verify the license terms with the maintainer before using in a commercial or compliance-sensitive context.
Install
timing-asgi on PyPI
pip
pip install timing-asgiuv
uv add timing-asgipoetry
poetry add timing-asgiInstalling timing-asgi
Before you install
Low friction: zero runtime dependencies, pure Python wheel, and actively maintained with recent commits. Requires Python 3.10 or later.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata, so you cannot verify the terms before use.
Quickstart
pip install timing-asgi
from timing_asgi import TimingMiddleware, TimingClient
from timing_asgi.integrations import StarletteScopeToName
class PrintTimings(TimingClient):
def timing(self, metric_name, timing, tags):
print(metric_name, timing, tags)
app.add_middleware(
TimingMiddleware,
client=PrintTimings(),
metric_namer=StarletteScopeToName(prefix="myapp", starlette_app=app)
)
Requires Python 3.10 or later; only supports ASGI3 (ASGI2 support ended at version 0.1.2).
Verify before relying
- Whether the package is licensed under an open-source or proprietary license—metadata does not declare one.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 178 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 628,117/month — #5,677 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: timing_asgi-0.3.2-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-asgiProvides ASGI middleware for OpenTelemetry that…
permissive · top 1,000 on PyPI
opentelemetry-util-httpProvides ASGI and WSGI middleware and HTTP…
permissive · top 1,000 on PyPI
asgi-correlation-idASGI middleware that reads or generates…
permissive · top 5,000 on PyPI
asgi-lifespanProgrammatically trigger ASGI application…
permissive · top 5,000 on PyPI
aiodogstatsdAn asyncio-based client for sending metrics to…
permissive · top 15,000 on PyPI
judoscaleJudoscale is a Python adapter that integrates…
permissive · top 15,000 on PyPI
aioprometheusA Prometheus client library for asyncio…
permissive · top 15,000 on PyPI
brotli-asgiBrotliMiddleware adds Brotli compression to…
permissive · top 15,000 on PyPI
aiohttp-asgi-connectorProvides an AIOHTTP connector that lets you…
permissive · top 15,000 on PyPI
ipython-autotimeIPython extension that automatically measures…
permissive · top 15,000 on PyPI