Skip to content

Telemetry cleanup and update#366

Merged
rodrigobr-msft merged 9 commits intomainfrom
users/robrandao/telemetry-update
Apr 15, 2026
Merged

Telemetry cleanup and update#366
rodrigobr-msft merged 9 commits intomainfrom
users/robrandao/telemetry-update

Conversation

@rodrigobr-msft
Copy link
Copy Markdown
Contributor

This pull request makes several improvements and corrections to telemetry, tracing, and metrics across the agents hosting core libraries. The main themes are standardizing span and metric names, improving attribute consistency, enhancing error handling and success tracking, and adding new telemetry for key operations. These changes will make telemetry data more consistent, easier to analyze, and more reliable for debugging and monitoring.

Telemetry naming and attribute standardization:

  • Updated span and metric names throughout the codebase to use consistent snake_case naming (e.g., SPAN_REPLY_TO_ACTIVITY is now "agents.connector.reply_to_activity", and SPAN_TURN_SEND_ACTIVITY is now "agents.turn.send_activities"). [1] [2] [3] [4] [5]
  • Standardized telemetry attribute keys (e.g., IS_AGENTIC is now "activity.is_agentic_request" and added a new SUCCESS attribute). [1] [2]

Improved telemetry recording and error handling:

  • Added the SUCCESS attribute to span metrics and ensured that turn duration is recorded on both success and error paths. Also, exceptions are now recorded on error. [1] [2] [3] [4] [5]
  • Refactored how attributes are extracted and set on spans, removing redundant code and ensuring all relevant attributes are consistently included. [1] [2]

New and enhanced telemetry spans:

  • Introduced a new AdapterWriteResponse span to capture when an InvokeResponse is written in the adapter, including metrics for activities sent. [1] [2] [3]
  • Added spans for send_activities in TurnContext, improving visibility into activity sends. [1] [2]

Storage telemetry improvements:

  • Refactored storage span wrappers to use operation names ("read", "write", "delete") as attributes, improving clarity and consistency in storage operation metrics. [1] [2]

Other fixes and improvements:

  • Ensured default values from factories are cached in agent state for tracking modifications.
  • Set default values for fields in models where appropriate (e.g., SuggestedActions.to).

These changes collectively make telemetry data more robust, easier to interpret, and better aligned with best practices for observability.

Copilot AI review requested due to automatic review settings April 15, 2026 18:18
@rodrigobr-msft rodrigobr-msft marked this pull request as ready for review April 15, 2026 18:18
@rodrigobr-msft rodrigobr-msft requested a review from a team as a code owner April 15, 2026 18:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR standardizes telemetry span/metric naming and attributes across hosting-core, improves span error recording and success tracking, and adds new spans/metrics coverage via tests.

Changes:

  • Standardized span names/attributes (snake_case, consistent keys) and added a success attribute for turn telemetry.
  • Added/updated span wrappers (e.g., AdapterWriteResponse, TurnContextSendActivities) and adjusted storage metric attributes to use short operation names.
  • Expanded telemetry unit tests for connector, adapter, storage, and user-token client spans.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/hosting_core/telemetry/test_user_token_client_spans.py Adds coverage for user token client spans/metrics + error status behavior
tests/hosting_core/telemetry/test_turn_context_spans.py Updates tests for renamed TurnContext send-activities span
tests/hosting_core/telemetry/test_storage_spans.py Adds assertions for storage.operation metric attribute values
tests/hosting_core/telemetry/test_simple_span_wrapper.py Removes completion-event test now that completion event was removed
tests/hosting_core/telemetry/test_http_adapter_telemetry.py Adds end-to-end adapter telemetry tests for multiple code paths
tests/hosting_core/telemetry/test_connector_spans.py Adds connector span/metric coverage for multiple operations
tests/hosting_core/telemetry/test_app_spans.py Adds test that turn duration is recorded on error path
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/turn_context.py Wraps send_activities with a telemetry span
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/turn_context/spans.py Renames span wrapper to TurnContextSendActivities and updates span constant
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/turn_context/constants.py Renames span name constant to agents.turn.send_activities
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/core/_agents_telemetry.py Removes completion event, records exceptions explicitly, configures tracer span behavior
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/attributes.py Updates IS_AGENTIC attribute key and adds SUCCESS
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/adapter/spans.py Adds AdapterWriteResponse span wrapper
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/adapter/constants.py Adds SPAN_WRITE_RESPONSE constant
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/storage/telemetry/spans.py Changes storage metrics to use short operation names + adds span attribute
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/state/agent_state.py Caches default factory values to track modifications
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_adapter_base.py Wraps invoke/expectReplies response writing in new adapter span
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/telemetry/user_token_client_spans.py Refactors attribute map creation for token client spans
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/telemetry/constants.py Standardizes connector span names to snake_case
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py Refactors update_activity request/response handling (introduces a bug)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/telemetry/constants.py Standardizes auth span names under agents.authentication.*
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/telemetry/spans.py Adds success attr and records duration on error path
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/telemetry/constants.py Renames oauth metric constants for sign-in/out
libraries/microsoft-agents-activity/microsoft_agents/activity/suggested_actions.py Sets default value for SuggestedActions.to

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/hosting_core/telemetry/test_http_adapter_telemetry.py
Copilot AI review requested due to automatic review settings April 15, 2026 19:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/hosting_core/telemetry/test_http_adapter_telemetry.py
Comment thread tests/hosting_core/telemetry/test_turn_context_spans.py
Comment thread tests/hosting_core/telemetry/test_turn_context_spans.py
@rodrigobr-msft rodrigobr-msft merged commit cca4c1d into main Apr 15, 2026
16 checks passed
@rodrigobr-msft rodrigobr-msft deleted the users/robrandao/telemetry-update branch April 15, 2026 21:16
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.

3 participants