Serverless flush
Telemetry missing on serverless or in a short script? Drain before the process freezes.
Your handler works, but only some calls — or none — reach the dashboard. On AWS Lambda, Vercel functions, Cloud Functions, Cloud Run, or any short-lived script, the cause is almost always the same: usage is sent in the background, and the process froze or exited before it went out.
The fix, shape by shape
| Where you run | Python | Node |
|---|---|---|
| Long-running server | nothing needed | nothing needed |
| Serverless function | tp.flush_sync() in finally | await tp.flush() in finally |
| Script / CLI / batch | tp.flush_sync() at the end | await tp.shutdown() at the end |
Put the drain in a finally so it still runs when the handler throws.
Node's flushSync() drains nothing. It is diagnostic-only — it reports pending state and
returns. The calls that actually drain are await tp.flush() and await tp.shutdown(). Python's
flush_sync() does drain; the two SDKs differ here.
Setting deployment="serverless" in init() switches the SDK to its short-lived path but
does not flush for you — you still wire one of the drains above.
Wrapper helpers (tp.serverless(...) / @tp.serverless), the Node async-handler caveat, and the
edge-runtime limits are all in
Flushing & serverless.

