Instrumentation Model
UseObserve.initialize() once at application startup to configure the OpenTelemetry provider, exporter, resource attributes, and supported AI SDK instrumentations.
Initialize
Initialize Observe
Initialize Options
Observe.initialize() may only be called once per process configuration. Call Observe.shutdown() before reinitializing with different options. A later Observe.initialize({ instrumentModules }) call can patch additional modules without replacing the provider.
Instrument Modules
Pass modules toinstrumentModules when they may be loaded before auto-instrumentation runs.
Patch already-loaded modules during initialization
Patch Modules After Initialization
UseObserve.patch() when the SDK has already initialized and a module needs to be instrumented later, such as inside a framework-specific module boundary.
Patch modules after initialization
Observe.patch() requires at least one module. It applies supported OpenLLMetry instrumentation and wraps Claude Agent SDK query functions when the module object is writable.
Existing OpenTelemetry Providers
If your application already owns OpenTelemetry setup, useObserve.instrumentations() with your provider instead of calling Observe.initialize() twice.
Reuse an existing OpenTelemetry provider
spanExporter, spanProcessor, or spanProcessors to Observe.initialize().
