TracingGuides

Delivery & runtimes

How runs reach Trodo without slowing your agent: background sending on servers, sending before return on serverless, and flushing before a script exits.

The SDK never makes your agent wait on Trodo. How it sends depends on where your code runs, and it picks the right way for you.

Servers: in the background

On a long-running server, wrapAgent returns as soon as your function does. The finished run goes into a queue, and a background sender posts queued runs to Trodo every second, or every 50 runs. If Trodo is slow or unreachable, the sender keeps retrying for up to 10 minutes. Your agent's latency never includes Trodo.

The queue is flushed when the process exits normally.

Serverless: before returning

Serverless platforms freeze the process between requests, so a background queue might never get to send. On these platforms the SDK sends the run before wrapAgent returns, with short retries (at most 15 seconds):

PlatformDetected by
AWS LambdaAWS_LAMBDA_FUNCTION_NAME, LAMBDA_TASK_ROOT
Google Cloud Functions, Cloud RunFUNCTION_TARGET, FUNCTION_NAME, K_SERVICE
VercelVERCEL
NetlifyNETLIFY
Azure FunctionsFUNCTIONS_WORKER_RUNTIME

await the wrapAgent call (Python: let the with block finish) before your handler returns, and nothing else is needed.

Scripts and batch jobs

A script that exits right after its last run should flush first:

await trodo.flush();      // send everything queued
// or, at the very end of the process:
await trodo.shutdown();
trodo.flush()      # send everything queued
# or, at the very end of the process:
trodo.shutdown()

Choosing the mode yourself

Set delivery in init: 'background', 'immediate', or 'auto' (the default, which picks per the table above).

trodo.init({ siteId, delivery: 'immediate' });

If you force 'background' on a serverless platform, call await trodo.flush() before each handler returns.

When something doesn't arrive

trodo.deliveryStats() (Python: delivery_stats() on the client that trodo.init returns) reports what is queued, in flight, sent and dropped, with a reason for each drop. A run is dropped only after 10 minutes of failed retries, when the queue is full (10,000 runs or 64 MB, oldest first), or when the server refuses it as too large. With debug: true in init, every send and every error is logged.

A burst faster than your plan's traces per minute is held by Trodo and stored at your plan's rate, not dropped.

On this page