Skip to main content
This module provides automatic instrumentation for the OpenAI Node.js SDK. which may be used in conjunction with @opentelemetry/sdk-trace-node.

Install

Setup

To instrument your application, import and enable OpenAIInstrumentation Create the instrumentation.js file:

Run OpenAI

Import the instrumentation.js file first, then use OpenAI as usual.

Observe

After setting up instrumentation and running your OpenAI application, traces will appear in the Phoenix UI for visualization and analysis.

Custom Tracer Provider

You can specify a custom tracer provider for OpenAI instrumentation in multiple ways:

Method 1: Pass tracerProvider on instantiation

Method 2: Set tracerProvider after instantiation

Method 3: Pass tracerProvider to registerInstrumentations

Resources