Skip to content

Conversation

@fenilfaldu
Copy link
Contributor

📥 Pull Request

closes #1082

📘 Description

  • Implemented custom wrappers for OpenAI's Chat Completions and Responses APIs to support streaming functionality.
  • Introduced OpenaiStreamWrapper and ResponsesAPIStreamWrapper classes for handling streaming responses and collecting telemetry data.
  • Enhanced the OpenaiInstrumentor to include streaming metrics and error handling.
  • Updated example scripts to demonstrate streaming usage and added checks for chunk content.
  • Refactored chat attribute handling to ensure non-null values are processed correctly.
  • Added new span attributes for streaming metrics in span_attributes.py.

🧪 Testing
Tested all the openai examples

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 12.44635% with 408 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...instrumentation/providers/openai/stream_wrapper.py 9.11% 399 Missing ⚠️
...s/instrumentation/providers/openai/instrumentor.py 70.00% 6 Missing ⚠️
.../instrumentation/providers/openai/wrappers/chat.py 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Dwij1704 Dwij1704 merged commit 38aa72c into main Jun 18, 2025
9 of 10 checks passed
@Dwij1704 Dwij1704 deleted the fix_openai_stream branch June 18, 2025 23:40
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.

[Bug]: Token Usage Extraction Across OpenAI API Endpoints

3 participants