[draft][VoiceLive] Add OpenTelemetry tracing support with GenAI semantic conventions#45857
Open
[draft][VoiceLive] Add OpenTelemetry tracing support with GenAI semantic conventions#45857
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in OpenTelemetry tracing layer to azure-ai-voicelive to provide GenAI-semconv-aligned observability for VoiceLive WebSocket sessions, plus documentation, samples, and unit tests.
Changes:
- Introduces
azure.ai.voicelive.telemetrywith aVoiceLiveInstrumentorthat monkey-patches connection lifecycle + send/recv/close to emit spans and GenAI/voice attributes. - Adds telemetry samples (console, Azure Monitor, custom attributes, content recording) and updates samples README.
- Adds unit tests and updates changelog for the new preview feature.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_voicelive_instrumentor.py | Implements monkey-patching and span/event/attribute emission for connect/send/recv/close. |
| sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_utils.py | Defines semantic attribute constants and start_span helper. |
| sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/init.py | Exposes VoiceLiveInstrumentor as public API. |
| sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/README.md | Documents architecture, setup, attributes/events, and troubleshooting. |
| sdk/voicelive/azure-ai-voicelive/samples/telemetry/sample_voicelive_with_console_tracing.py | Console exporter sample showing end-to-end tracing usage. |
| sdk/voicelive/azure-ai-voicelive/samples/telemetry/sample_voicelive_with_azure_monitor_tracing.py | Azure Monitor exporter sample for Application Insights. |
| sdk/voicelive/azure-ai-voicelive/samples/telemetry/sample_voicelive_with_console_tracing_custom_attributes.py | Demonstrates adding custom attributes via a custom span processor. |
| sdk/voicelive/azure-ai-voicelive/samples/telemetry/sample_voicelive_with_content_recording.py | Demonstrates opt-in message content capture into span events. |
| sdk/voicelive/azure-ai-voicelive/samples/README.md | Adds a telemetry samples section and prerequisite installs. |
| sdk/voicelive/azure-ai-voicelive/tests/test_unit_telemetry.py | Adds unit tests for instrumentation state, attributes, events, and counters. |
| sdk/voicelive/azure-ai-voicelive/CHANGELOG.md | Adds release notes entry for tracing support and telemetry attributes/events. |
sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_voicelive_instrumentor.py
Show resolved
Hide resolved
sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_voicelive_instrumentor.py
Show resolved
Hide resolved
sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_voicelive_instrumentor.py
Show resolved
Hide resolved
sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_utils.py
Outdated
Show resolved
Hide resolved
...re-ai-voicelive/samples/telemetry/sample_voicelive_with_console_tracing_custom_attributes.py
Show resolved
Hide resolved
sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/telemetry/_voicelive_instrumentor.py
Show resolved
Hide resolved
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
…_voicelive_instrumentor.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_utils.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…iability - Attach connect span to OTel context so send/recv/close spans are parented under it (bypasses azure-core suppression for CLIENT spans) - Detach context token in __aexit__ to restore previous context - Update recv spans to include event type in name (e.g. 'recv session.created') - Replace brittle MagicMock + del .get pattern with types.SimpleNamespace in test_extract_session_id_from_object and test_error_event_with_object_result
added 6 commits
March 23, 2026 15:33
…only params, remove unused imports
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.
Summary
VoiceLive Telemetry — Design Doc
SDK:
azure-ai-voicelive1.2.0b5Pattern: Monkey-patching (same as
azure-ai-agentsAgentsInstrumentor)Service impact: None — purely client-side
Overview
Opt-in OpenTelemetry tracing for VoiceLive WebSocket sessions. When enabled, the SDK automatically emits spans for connect, send, recv, and close — with voice-specific attributes and session-level counters. Follows GenAI Semantic Conventions v1.34.0.
Activation
AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING=true(matchesazure-ai-agents)VoiceLiveInstrumentor().instrument()OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true— off by default for privacySpan Structure
A parent connect span lives for the entire WebSocket session. All send/recv/close operations are child spans:
What We Track
Session-level (on the connect span, flushed at session close)
gen_ai.voice.session_idsession.created/session.updatedrecvgen_ai.voice.input_audio_formatpcm16)session.updatesendgen_ai.voice.output_audio_formatsession.updatesendgen_ai.voice.turn_countresponse.donerecvgen_ai.voice.interruption_countresponse.cancelsendgen_ai.voice.audio_bytes_sentinput_audio_buffer.append(base64-decoded)gen_ai.voice.audio_bytes_receivedresponse.audio.delta(base64-decoded)gen_ai.voice.first_token_latency_msresponse.createsend → first delta recvgen_ai.request.modelserver.address/server.portPer-message (on each send/recv span)
gen_ai.voice.event_type"response.done")gen_ai.voice.message_sizegen_ai.usage.input_tokensresponse.done)gen_ai.usage.output_tokensresponse.done)Span events
gen_ai.input.messagesgen_ai.output.messagesgen_ai.voice.errorgen_ai.voice.rate_limits.updatedStandard attributes (every span)
az.namespace="Microsoft.CognitiveServices"·gen_ai.system="az.ai.voicelive"·gen_ai.operation.name=connect/send/recv/closeUsage Examples
Basic: Console tracing
Azure Monitor
Content recording (captures full message payloads)
Custom span processing (e.g., add extra attributes)
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines