Typing activity span definition and new zero-code OTEL sample - #555
Draft
Rodrigo Brandão (rodrigobr-msft) wants to merge 2 commits into
Draft
Typing activity span definition and new zero-code OTEL sample#555Rodrigo Brandão (rodrigobr-msft) wants to merge 2 commits into
Rodrigo Brandão (rodrigobr-msft) wants to merge 2 commits into
Conversation
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
August 21, 2026 17:35
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Microsoft 365 Agents SDK for Python with OpenTelemetry support in two ways: (1) adding a new, explicitly named typing-indicator span in hosting-core, and (2) introducing two runnable OpenTelemetry sample projects (manual “quickstart” and “zero-code” auto-instrumentation) under test_samples/otel.
Changes:
- Added a new
agents.app.send_typingspan (TypingSendTyping) and wrappedTypingIndicator._send_typing()with it. - Added tests to validate typing span creation (unit + telemetry span wrapper coverage).
- Added OpenTelemetry sample projects:
quickstart(explicit SDK setup) andzero-code(env-driven auto-instrumentation), including configs, scripts, and a custom sampler plugin.
Reviewed changes
Copilot reviewed 21 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/typing_indicator.py | Wrap typing-indicator send operation in a telemetry span. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/telemetry/spans.py | Add TypingSendTyping span wrapper. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/telemetry/constants.py | Add SPAN_SEND_TYPING span name constant. |
| tests/hosting_core/telemetry/test_app_spans.py | Add unit test validating the new TypingSendTyping span wrapper. |
| tests/hosting_core/app/test_typing_indicator.py | Add integration-style test validating span emission when sending typing. |
| test_samples/otel/requirements.txt | Remove old shared requirements file (samples now use per-project pyproject.toml). |
| test_samples/otel/quickstart/start_dashboard.ps1 | Script to run Aspire dashboard for local OTEL visualization. |
| test_samples/otel/quickstart/src/telemetry.py | Manual OpenTelemetry provider/exporter setup + instrumentation hooks. |
| test_samples/otel/quickstart/src/start_server.py | aiohttp server bootstrap for the quickstart sample. |
| test_samples/otel/quickstart/src/main.py | Quickstart entrypoint wiring telemetry + agent + server startup. |
| test_samples/otel/quickstart/src/get_user_info.py | Helper to call Microsoft Graph /me for the sample. |
| test_samples/otel/quickstart/src/card.py | Helper to build an Adaptive Card profile response. |
| test_samples/otel/quickstart/src/agent.py | Sample agent behavior tweaks (removal of stray return). |
| test_samples/otel/quickstart/src/init.py | Package marker for the quickstart sample. |
| test_samples/otel/quickstart/README.md | Quickstart sample setup/run documentation. |
| test_samples/otel/quickstart/pyproject.toml | Quickstart sample dependencies and local editable SDK wiring. |
| test_samples/otel/quickstart/env.TEMPLATE | Quickstart environment template for auth + OTEL endpoint/config. |
| test_samples/otel/zero-code/tests/test_typing_sampler.py | Tests for custom sampler dropping typing spans/descendants. |
| test_samples/otel/zero-code/start_dashboard.ps1 | Script to run Aspire dashboard for local OTEL visualization. |
| test_samples/otel/zero-code/start_agent.ps1 | Script to run the agent via opentelemetry-instrument. |
| test_samples/otel/zero-code/src/typing_sampler.py | Custom sampler plugin to drop typing spans. |
| test_samples/otel/zero-code/src/start_server.py | aiohttp server bootstrap for the zero-code sample. |
| test_samples/otel/zero-code/src/main.py | Zero-code entrypoint wiring agent + server startup. |
| test_samples/otel/zero-code/src/get_user_info.py | Helper to call Microsoft Graph /me for the sample. |
| test_samples/otel/zero-code/src/card.py | Helper to build an Adaptive Card profile response. |
| test_samples/otel/zero-code/src/agent.py | Zero-code sample agent implementation (behavior + auth flow). |
| test_samples/otel/zero-code/src/init.py | Package marker for the zero-code sample. |
| test_samples/otel/zero-code/README.md | Zero-code sample setup/run documentation (env-based OTEL config). |
| test_samples/otel/zero-code/pyproject.toml | Zero-code sample dependencies + sampler entry point registration. |
| test_samples/otel/zero-code/env.TEMPLATE | Zero-code environment template for auth + OTEL distro config. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ) | ||
| from microsoft_agents.hosting.core.app.telemetry import constants | ||
|
|
||
| from tests._common.fixtures.telemetry import test_telemetry, test_exporter |
| trace_id: int, | ||
| name: str, | ||
| kind: SpanKind | None = None, | ||
| attributes: Attributes = None, |
Comment on lines
+20
to
+23
| OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST=".*" | ||
| OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE=".*" | ||
| OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST=".*" | ||
| OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE=".*" |
| if response.status == 200: | ||
| return await response.json() | ||
| error_text = await response.text() | ||
| raise Exception(f"Error from Graph API: {response.status} - {error_text}") |
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.
This pull request introduces two new OpenTelemetry sample projects under
test_samples/otel: a "quickstart" sample with explicit SDK configuration and a "zero-code" sample using auto-instrumentation. These samples demonstrate how to integrate Microsoft 365 Agents SDK with OpenTelemetry, providing both manual and environment-based approaches. The main changes include new sample code, configuration templates, and documentation for both approaches.New OpenTelemetry sample projects:
Quickstart sample (manual configuration):
test_samples/otel/quickstartwith full agent implementation, OpenTelemetry provider setup insrc/telemetry.py, and manual library instrumentation. Includes agent logic (src/agent.py), profile card rendering (src/card.py), user info retrieval (src/get_user_info.py), server startup (src/start_server.py), and main entry point (src/main.py). [1] [2] [3] [4] [5] [6]env.TEMPLATE) and project dependencies (pyproject.toml) for local development and testing. [1] [2]Zero-code sample (auto-instrumentation):
test_samples/otel/zero-codedemonstrating OpenTelemetry auto-instrumentation with configuration via environment variables only, no explicit SDK setup in code.env.TEMPLATE) and project dependencies (pyproject.toml), registering a custom sampler entry point. [1] [2]These additions provide clear examples for integrating OpenTelemetry into Microsoft 365 Agents SDK projects, covering both manual and zero-code instrumentation workflows.