feat(openai): Instrument structured outputs (chat.completions.parse)#4416
feat(openai): Instrument structured outputs (chat.completions.parse)#4416Nik-Reddy wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looking good, thanks @Nik-Reddy. I've left some suggestions and please can you add a changelog entry.
3ec82e7 to
6d00a12
Compare
|
Hi @MikeGoldsmith, I've addressed all three of your review comments:
Would appreciate a re-review when you get a chance. Thanks! |
6d00a12 to
ce2065f
Compare
|
Rebased on latest main. All review feedback @MikeGoldsmith addressed:
|
There was a problem hiding this comment.
There are some unused imports here; I would suggest running ruff formatting/linting
|
Thanks for the updates, the changes look good. One thing still to address — there are unused imports in This needs to be done before we can accept. Also, I want to raise something directly: the responses to review feedback have been very fast and follows a pattern that suggests an automated agent may be posting comments on your behalf. As per our AGENTS.md at the root of this project, discussions on OpenTelemetry repositories are for humans only — AI-generated comments on issues and PRs are not permitted. Please ensure that all review responses and PR comments are written and posted by you directly. Thanks for understanding. |
3cbb955 to
9a7ae07
Compare
|
@dehanjl good catch on the unused imports. Cleaned those up, dropped Rebased on latest main as well. |
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Ci is failing because of a new test that was added. precommit check is still failing too.
Please take a look 👍🏻
| ) | ||
|
|
||
|
|
||
| def test_structured_output_no_content( |
There was a problem hiding this comment.
This test is failing CI - please fix it.
Description
The OpenAI v2 instrumentation currently wraps
chat.completions.create()but notchat.completions.parse(). Theparse()method is used for structured outputs. Calls toparse()generate zero telemetry even when instrumentors are configured.This PR adds instrumentation for both sync and async
parse()methods, reusing the existing chat completion wrapper logic.Fixes #3449
Changes
_is_parse_supported()version guard and wrap/unwrap calls for parse methodsresponse_formatbeing a Python type by recordingjson_schemaas the output type attributeType of change
How Has This Been Tested?
All 8 new tests pass. All 84 existing tests continue to pass.
Checklist: