FastAPI

APM transaction timing excludes request body streaming latency

warning
performanceUpdated Dec 13, 2023(via Exa)
How to detect:

In elastic-apm versions 6.12-6.19 with capture_body disabled, FastAPI/Starlette APM transaction timing starts after request body is fully consumed, excluding body streaming latency from traces. This causes metrics to show artificially low latency: 40% lower on average, up to 500% lower for payloads >50KB, masking actual end-user experience.

Recommended action:

Verify actual end-to-end latency using external timing tools (curl with timing) to compare against APM metrics. If accurate body streaming measurement is required, upgrade to elastic-apm version containing fix from PR #1970. Note: applying the fix will increase displayed latency in dashboards, but this reflects true user experience. Monitor correlation between http.server.request.size and latency discrepancies.