Skip to content

feat(oauth): add telemetry for multioauth/state - #587

Merged
Lily Du (lilyydu) merged 5 commits into
mainfrom
lilyydu-oauth-telemetry-parity
Sep 3, 2026
Merged

feat(oauth): add telemetry for multioauth/state#587
Lily Du (lilyydu) merged 5 commits into
mainfrom
lilyydu-oauth-telemetry-parity

Conversation

@lilyydu

Copy link
Copy Markdown
Collaborator

Summary

aligns PY OAuth and state telemetry with TS and C#

  • records a separate verifyState span and metric for each OAuth connection attempt
  • adds sign-in telemetry for cached-token, card-sent, and failure outcomes
  • adds exception-aware spans for state load, save, and delete operations
  • preserves existing OAuth routing, callback, response, and state behavior
  • adds focused coverage for multi-connection attempts and telemetry error paths

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 1, 2026 23:23

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.

🟢 Approval recommended

The changes are well-covered by focused tests and appear behavior-preserving; only minor log-message formatting nits were found.

Pull request overview

This PR extends the Python Teams SDK’s diagnostics to align OAuth and state telemetry with the TypeScript/C# implementations, adding spans/metrics for key OAuth outcomes and state persistence operations while keeping the functional OAuth/state behavior intact.

Changes:

  • Add exception-aware OpenTelemetry spans around state load/save/delete operations in TurnStateLoader.
  • Record OAuth signin span/metrics with outcome attribution (cached token vs sign-in card vs failure) in OAuthFlow.sign_in.
  • Refactor signin/verifyState probing to emit per-connection telemetry and add targeted tests covering multi-connection attempts and error paths.
File summaries
File Description
packages/apps/src/microsoft_teams/apps/state/loader.py Wrap state operations with traced spans and exception recording.
packages/apps/src/microsoft_teams/apps/oauth_flow.py Add signin span + metrics with result/error attribution and duration.
packages/apps/src/microsoft_teams/apps/diagnostics/_constants.py Introduce new OAuth operation/result constants and new span names for state + signin.
packages/apps/src/microsoft_teams/apps/app_oauth.py Emit verify_state telemetry per candidate connection attempt; preserve routing behavior.
packages/apps/tests/test_state.py Add coverage ensuring state spans are created and storage exceptions are recorded.
packages/apps/tests/test_oauth_flow.py Add coverage for signin telemetry across success, card-sent, and failure paths.
packages/apps/tests/test_app_oauth.py Add coverage asserting per-connection verify_state spans/metrics across multiple candidates.
Review details

Suppressed comments (2)

packages/apps/src/microsoft_teams/apps/app_oauth.py:757

  • This error log message concatenates two f-strings without a separating space, which yields ... in conversationc1: in logs.
                    logger.error(
                        f"Error verifying sign-in state for user {activity.from_.id} in conversation"
                        f"{activity.conversation.id}: {e}"
                    )

packages/apps/src/microsoft_teams/apps/app_oauth.py:776

  • Same missing-space issue in the exception-path error log: two adjacent f-strings are concatenated without whitespace, producing ... in conversationc1:.
                    logger.error(
                        f"Error verifying sign-in state for user {activity.from_.id} in conversation"
                        f"{activity.conversation.id}: {e}"
                    )
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/apps/src/microsoft_teams/apps/app_oauth.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread packages/apps/src/microsoft_teams/apps/diagnostics/_constants.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/diagnostics/_constants.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/app_oauth.py Outdated
@lilyydu
Lily Du (lilyydu) merged commit 440a14a into main Sep 3, 2026
8 checks passed
@lilyydu
Lily Du (lilyydu) deleted the lilyydu-oauth-telemetry-parity branch September 3, 2026 22:38
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