Advanced Speed Monitoring

Set SLAs, configure alert thresholds, and expose performance metrics to clients.

SLA Monitoring

Configure warning and error thresholds to automatically log when execution times exceed your Service Level Agreements.

routes/critical.py
# SLA Monitoring
# Warns if > 100ms, Errors if > 500ms
@speed(warn_threshold_ms=100, error_threshold_ms=500)
async def critical_path(): ...

Client Transparency

Automatically add an X-Response-Time header to the HTTP response to let clients know how long the request took to process.

routes/public.py
# Client Transparency
# Returns header: X-Response-Time: 12.5ms
@speed(include_in_response=True)
async def public_api(): ...

Detailed Signature

def speed(
    func=None, *, 
    warn_threshold_ms: float = None, 
    error_threshold_ms: float = None, 
    include_in_response: bool = False
)
  • warn_threshold_ms: Log a warning if execution time exceeds this value (ms).
  • error_threshold_ms: Log an error if execution time exceeds this value (ms).
  • include_in_response: If True, adds X-Response-Time header to the HTTP response.