feat(genai-openai): OpenAI responses extractors#4337
feat(genai-openai): OpenAI responses extractors#4337xrmx merged 23 commits intoopen-telemetry:mainfrom
Conversation
|
Question: isn't openai using pydantic itself and so aren't its answer expected to be of the expected shape? |
Howdy Riccardo, yep OpenAI uses pydantic. We’re using Pydantic here to validate and normalize the minimal request/response shapes that the instrumentation depends on. The local models let us avoid Any, handle the supported inputs through one path, and fail closed by logging and returning empty values instead of letting extraction errors break telemetry. In a nutshell I am using pydantic for following reasons:
Lmk your thoughts. |
instrumentation-genai/opentelemetry-instrumentation-openai-v2/pyproject.toml
Outdated
Show resolved
Hide resolved
… compatible with openai supported version.
...instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/response_extractors.py
Outdated
Show resolved
Hide resolved
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looks good to me. I've left a suggestion around testing but not blocking.
Description
This change adds strongly typed Responses API extractors for openai-v2 and reduces dependence on Any, based on feedback we received on the sync Anthropic SDK instrumentation. Pydantic models are used
here to:
Dependencies required for this change:
Fixes #3436 partly
Type of change
How Has This Been Tested?
Focused extractor tests were added/updated to cover:
Reproduce with:
python3 -m pytest --noconftest instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_response_extractors.py
Test result in local environment:
Does This PR Require a Core Repo Change?
Checklist: