open-telemetry / open-telemetry/opentelemetry-python-genai

Instrument Responses.parse and AsyncResponses.parse

Open
#659 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
39
Forks
63
Avg merge
1d 15h
Merged PRs (30d)
175

Description

What problem do you want to solve?

opentelemetry-instrumentation-genai-openai instruments Responses.create() and AsyncResponses.create(), but not Responses.parse() or AsyncResponses.parse().

As a result, applications using the Responses API structured-output helper do not emit a GenAI span:

from openai import AsyncOpenAI
from pydantic import BaseModel

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

client = AsyncOpenAI()

response = await client.responses.parse(
    model="gpt-4o-mini",
    input="Alice and Bob are going to a science fair on Friday.",
    text_format=CalendarEvent,
)

Responses.parse() calls the SDK's request path directly rather than delegating to the instrumented Responses.create() method. Therefore, instrumenting create() does not cover this API.

This differs from chat.completions.parse(), which is already instrumented by #18. That PR explicitly did not change the Responses API path.

I could not find an existing issue or pull request covering Responses.parse() or AsyncResponses.parse().

Describe the solution you'd like

Instrument both methods when they are available in the installed OpenAI SDK:

  • openai.resources.responses.responses.Responses.parse
  • openai.resources.responses.responses.AsyncResponses.parse

The implementation could reuse the existing Responses API invocation and response extraction logic used by Responses.create().

Describe alternatives you've considered

No response

Additional Context
  • openai==3.0.0
  • opentelemetry-instrumentation-genai-openai==1.0b0

The current instrumentation source also registers Responses API create, stream, and retrieve, but does not register Responses.parse or AsyncResponses.parse.

Would you like to implement it?

None

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the instrumentation source that registers Responses API create, stream, and retrieve, then compare its existing invocation and response extraction logic with openai.resources.responses.responses.Responses.parse and AsyncResponses.parse. Add coverage for both parse methods when available in the installed OpenAI SDK, reusing the existing Responses behavior, and verify that structured-output calls emit a GenAI span.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.