Skip to content

Typing activity span definition and new zero-code OTEL sample - #555

Draft
Rodrigo Brandão (rodrigobr-msft) wants to merge 2 commits into
mainfrom
users/robrandao/typing-span
Draft

Typing activity span definition and new zero-code OTEL sample#555
Rodrigo Brandão (rodrigobr-msft) wants to merge 2 commits into
mainfrom
users/robrandao/typing-span

Conversation

@rodrigobr-msft

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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):

  • Added test_samples/otel/quickstart with full agent implementation, OpenTelemetry provider setup in src/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]
  • Provided configuration template (env.TEMPLATE) and project dependencies (pyproject.toml) for local development and testing. [1] [2]
  • Added a README with setup and usage instructions, and a script to run the Aspire dashboard. [1] [2]

Zero-code sample (auto-instrumentation):

  • Added test_samples/otel/zero-code demonstrating OpenTelemetry auto-instrumentation with configuration via environment variables only, no explicit SDK setup in code.
  • Included configuration template (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.

Copilot AI lite review requested due to automatic review settings August 21, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_typing span (TypingSendTyping) and wrapped TypingIndicator._send_typing() with it.
  • Added tests to validate typing span creation (unit + telemetry span wrapper coverage).
  • Added OpenTelemetry sample projects: quickstart (explicit SDK setup) and zero-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}")
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.

2 participants