Skip to content

Default OpenAI export not instrumented #17285

@andreiborza

Description

@andreiborza

When setting up an OpenAI client according to their documentation, Sentry does not instrument the ai calls.

// does not work - no Sentry ai spans recording
import OpenAI from "openai";

// works
import { OpenAI } from "openai";

const client = new OpenAI();
const response = await client.responses.create({
    model: "gpt-4.1",
    input: "Write a one-sentence bedtime story about a unicorn."
});

Tested this in an ESM based app with openai v4.104.0 and @sentry/node 10.0.0.

Rola: This happens only for default exports, we need to point the default export to the newly wrapped function.

Metadata

Metadata

Assignees

Labels

javascriptPull requests that update javascript codeopenai

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions