Skip to main content
Spans buffer in a background batch by default — 64 spans or a five-second interval, whichever comes first. A process that exits, or a function instance that freezes, before that batch exports loses those spans. This page is TypeScript-specific. Python services are long-lived in practice; for a Python script or job, call client.flush() in a finally block.

Export per span instead of batching

exportMode: "immediate" replaces the batcher with per-span export. Use it whenever the process lifetime is one request.
Still call flush() before returning — the export itself is asynchronous. ATLAN_DEBUG=true forces immediate mode as well, which is why debug runs surface a rejected export straight away.

Keep the instance alive with waitUntil

waitUntil hands every background flush promise to the platform, so the runtime keeps the instance alive until export finishes instead of freezing it mid-request.
On Vercel’s Node runtime, use after from next/server:
Cloudflare Workers have no ambient environment, so ATLAN_* variables are not readable. Pass apiKey, workspaceId, and everything else through init() from the Worker’s env binding.

CLIs and jobs

Node runs a best-effort flush on beforeExit, but being explicit is reliable:

Bundling for Cloudflare Workers

Wrangler users get what they need from compatibility_flags = ["nodejs_compat"] with a recent compatibility_date. For a direct esbuild bundle, this is the supported configuration — it matches the SDK’s own Workers smoke test:
Each flag is load-bearing: The SDK’s OTLP exporter chain is lazy-loaded, so injecting your own spanExporter keeps Worker startup clean.

Verify it works

Deploy, trigger one request, then confirm the trace appears in Agent Registry for that service_name. A 200 from your handler does not prove the export completed — a frozen instance returns successfully while dropping the batch. Check the trace, not the response.

Next steps

Configuration

Export modes, flush tuning, and every option.

Send and verify traces

Confirm ingestion end to end.