Skip to content

Add gen_ai.conversation.id instrumentation to OpenAI provider#1627

Draft
jimilp7 wants to merge 1 commit intopydantic:mainfrom
introspection-org:add-conversation-id-instrumentation
Draft

Add gen_ai.conversation.id instrumentation to OpenAI provider#1627
jimilp7 wants to merge 1 commit intopydantic:mainfrom
introspection-org:add-conversation-id-instrumentation

Conversation

@jimilp7
Copy link
Contributor

@jimilp7 jimilp7 commented Jan 13, 2026

Automatically extract and capture gen_ai.conversation.id from OpenAI's stateful APIs to comply with OTel GenAI semantic conventions.

Changes

  • Extract conversation ID from /responses endpoint request (conversation parameter)
  • Add handler for /conversations endpoint
  • Extract conversation ID from Response objects (both sync and streaming)
  • Extract conversation ID from conversation creation responses

@jimilp7 jimilp7 marked this pull request as draft January 13, 2026 22:31
@jimilp7 jimilp7 force-pushed the add-conversation-id-instrumentation branch from a2f004c to ddc75fa Compare January 13, 2026 22:34
## Subject
  Add `gen_ai.conversation.id` instrumentation to OpenAI provider

  ## Description
  Automatically extract and capture `gen_ai.conversation.id` from OpenAI's stateful APIs to comply with OTel GenAI semantic conventions.

  ### Changes
  - Extract conversation ID from `/responses` endpoint request (`conversation` parameter)
  - Add handler for `/conversations` endpoint
  - Extract conversation ID from Response objects (both sync and streaming)
  - Extract conversation ID from conversation creation responses

  ### Files Modified
  - `logfire/_internal/integrations/llm_providers/openai.py`
  - `tests/otel_integrations/test_openai.py`
@jimilp7 jimilp7 force-pushed the add-conversation-id-instrumentation branch from ddc75fa to 5b8d9ee Compare January 13, 2026 22:36
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ire/_internal/integrations/llm_providers/openai.py 93.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant