Skip to content

instrumentation-openai: breaks OpenAI parse and LangChain withStructuredOutput #3586

Description

@hien-prio

What version of OpenTelemetry are you using?

  • @opentelemetry/auto-instrumentations-node: 0.77.0
  • @opentelemetry/instrumentation-openai: 0.17.0

What version of Node are you using?

  • v24.14.1

What did you do?

Try to use instrumentation with a JSON structured output.

What did you expect to see?

Success

What did you see instead?

Instrumentation throws an error and parsing fails.

Run failed: TypeError: Body is unusable: Body has already been read
    at consumeBody (node:internal/deps/undici/undici:6961:31)
    at _Response.json (node:internal/deps/undici/undici:6912:18)
    at /home/hien/slim_dev/parse-error/node_modules/openai/internal/parse.js:36:41
    at APIPromise.defaultParseResponse [as parseResponse] (/home/hien/slim_dev/parse-error/node_modules/openai/internal/parse.js:41:7)
    at APIPromise.parseResponse (/home/hien/slim_dev/parse-error/node_modules/openai/core/api-promise.js:26:188)
    at /home/hien/slim_dev/parse-error/node_modules/openai/core/api-promise.js:60:75
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async runParse (/home/hien/slim_dev/parse-error/main.cjs:13:3)
    at async main (/home/hien/slim_dev/parse-error/main.cjs:44:3)

Additional context

Test case attached, example usage:

OPENAI_API_KEY=... npm run no-otel
OPENAI_API_KEY=... npm run otel

parse-error-repro.tar.gz

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpkg:instrumentation-openaipriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistencies

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions