feat(oauth): add telemetry for multioauth/state - #587
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 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
signinspan/metrics with outcome attribution (cached token vs sign-in card vs failure) inOAuthFlow.sign_in. - Refactor
signin/verifyStateprobing 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Mehak Bindra (MehakBindra)
approved these changes
Sep 3, 2026
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
aligns PY OAuth and state telemetry with TS and C#
verifyStatespan and metric for each OAuth connection attempt