Serverless Setup
InitializeObserve once in the earliest Node-only entrypoint. In Next.js, use instrumentation.ts and guard against the edge runtime:
Prerequisites
- Node.js 20 or newer.
- A Next.js app or another serverless Node.js runtime.
@asymptote/sdkinstalled.- Any agent SDKs used by your route handlers, such as Vercel AI SDK.
ASYMPTOTE_API_KEYset for Asymptote Managed hosted Observe, orOTEL_EXPORTER_OTLP_ENDPOINTset for customer-managed OTLP export. To get an Asymptote Managed API key, reach out for a demo.
Install the SDK and Vercel AI SDK
Next.js Instrumentation
Initialize in instrumentation.ts
Serverless Handlers
For short-lived serverless invocations, callObserve.flush() before returning if traces are created immediately before the process may terminate.
Flush traces in a serverless handler
Observe.shutdown() for graceful process shutdown rather than calling it after every request.
Customer-Managed OTLP
Serverless and preview environments can send to a customer-managed collector by settingOTEL_EXPORTER_OTLP_ENDPOINT instead of Asymptote Managed hosted Observe credentials.
Set the OTLP endpoint
Initialize with a customer-managed OTLP endpoint
ASYMPTOTE_API_KEY.
