Skip to main content

Serverless Setup

Initialize Observe 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/sdk installed.
  • Any agent SDKs used by your route handlers, such as Vercel AI SDK.
  • ASYMPTOTE_API_KEY set for Asymptote Managed hosted Observe, or OTEL_EXPORTER_OTLP_ENDPOINT set 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
This keeps SDK initialization out of edge runtimes while ensuring Node.js routes, server actions, and background work share the same tracing setup.

Serverless Handlers

For short-lived serverless invocations, call Observe.flush() before returning if traces are created immediately before the process may terminate.
Flush traces in a serverless handler
If the runtime owns a long-lived process, reserve 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 setting OTEL_EXPORTER_OTLP_ENDPOINT instead of Asymptote Managed hosted Observe credentials.
Set the OTLP endpoint
Initialize with a customer-managed OTLP endpoint
Explicit OTLP export does not require an Asymptote Managed ASYMPTOTE_API_KEY.