Fix MIME type inference logic for speech synthesis instrumentation#115
Merged
Cirilla-zmh merged 3 commits intoalibaba:mainfrom Feb 9, 2026
Merged
Fix MIME type inference logic for speech synthesis instrumentation#115Cirilla-zmh merged 3 commits intoalibaba:mainfrom
Cirilla-zmh merged 3 commits intoalibaba:mainfrom
Conversation
Change-Id: Iaafae7e5f7ad99f0df0cec5652415aa0231b9e25 Co-developed-by: Cursor <noreply@cursor.com>
Contributor
There was a problem hiding this comment.
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.
...te-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/multimodal.py
Show resolved
Hide resolved
...te-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/multimodal.py
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/tests/test_speech_synthesis.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-dashscope/CHANGELOG.md
Show resolved
Hide resolved
123liuziming
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.