PowerTraces

AI tracing: OpenAI / ChatGPT

Trace your app's calls to the OpenAI API, including the models behind ChatGPT, with the official OpenTelemetry instrumentation.

1. Python: install the instrumentation

Set up your service as in Connect first; this adds the OpenAI part.

pip install openai opentelemetry-instrumentation-openai-v2

2. Turn it on at start-up

Call it once, before you create the OpenAI client.

from opentelemetry.instrumentation.openai_v2 import OpenAIInstrumentor

OpenAIInstrumentor().instrument()

3. Use the latest conventions and keep the messages

The first line switches to the current GenAI attribute names. The second puts prompts and answers on the spans so the Agent tab can show them; leave it out to send counts and timings only.

OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=span_only

4. Node.js: add the instrumentation to the SDK

Add it to the instrumentations your OpenTelemetry setup already registers.

npm install @opentelemetry/instrumentation-openai

// powertraces.mjs
import { OpenAIInstrumentation } from '@opentelemetry/instrumentation-openai'

const sdk = new NodeSDK({
  instrumentations: [getNodeAutoInstrumentations(), new OpenAIInstrumentation()],
})

The ChatGPT app itself can't send telemetry; these steps trace the calls your own code makes. For the OpenAI Agents SDK, the OpenInference instrumentation openinference-instrumentation-openai-agents adds each agent step and tool call. OpenAI models have no built-in price in PowerTraces: set yours in AI › Settings to see their cost.

Prompts and answers

Most libraries send only counts and timings until you turn content on. When you do, PowerTraces keeps it, masks personal data, or drops it, as set in AI › Settings for each workspace.

Check it works

Make one model call, then open the AI page: the run appears within a minute. Open it to see each step in the Agent tab.

Other providers

All documentation