-
Notifications
You must be signed in to change notification settings - Fork 22
Fix MIME type inference logic for speech synthesis instrumentation #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Change-Id: Iaafae7e5f7ad99f0df0cec5652415aa0231b9e25 Co-developed-by: Cursor <noreply@cursor.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes MIME type inference logic for speech synthesis instrumentation by dynamically determining the correct MIME type based on the audio format parameter, rather than using hardcoded values. Additionally, it removes support for the V2 streaming_call functionality and improves time-to-first-token calculation safety.
Changes:
- Added
_convert_speech_format_to_mime_type()helper function to dynamically map DashScope audio format strings (wav, mp3, pcm, opus) to their corresponding MIME types - Changed from Base64Blob to Blob type for audio content storage, now using raw bytes instead of base64-encoded strings
- Removed instrumentation for
SpeechSynthesizerV2.streaming_callmethod (no longer supported) - Added guard condition to prevent negative time-to-first-token calculations in span_utils.py
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py | Added guard condition to prevent negative TTFT calculations when first token time precedes start time |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/tests/test_speech_synthesis.py | Disabled streaming_call test as functionality is no longer supported |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/multimodal.py | Added MIME type converter, changed from Base64Blob to Blob, added mime_type parameters to response handlers |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/init.py | Exported new _convert_speech_format_to_mime_type function |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/patch/speech_synthesis.py | Integrated MIME type inference, removed streaming_call wrapper |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/patch/init.py | Removed streaming_call wrapper export |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/init.py | Removed streaming_call instrumentation and uninstrumentation |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/README.rst | Added Speech Synthesis V1 and V2 to supported APIs documentation |
| instrumentation-loongsuite/loongsuite-instrumentation-dashscope/CHANGELOG.md | Added changelog entry for MIME type fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Change-Id: Iaafae7e5f7ad99f0df0cec5652415aa0231b9e25
Co-developed-by: Cursor noreply@cursor.com
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.