Skip to content

Instrument Responses.parse and AsyncResponses.parse #659

Description

@PLAYPANDA

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions