Skip to content

[Identity] Add cache hit debug logging#44963

Open
pvaneck wants to merge 2 commits intoAzure:mainfrom
pvaneck:identity-cache-logging
Open

[Identity] Add cache hit debug logging#44963
pvaneck wants to merge 2 commits intoAzure:mainfrom
pvaneck:identity-cache-logging

Conversation

@pvaneck
Copy link
Member

@pvaneck pvaneck commented Feb 3, 2026

Added some additional debug logging to provide insight into access token cache hits.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the identity-cache-logging branch from 7fa9b02 to aa0723c Compare February 3, 2026 19:22
@pvaneck pvaneck marked this pull request as ready for review February 3, 2026 21:46
@pvaneck pvaneck requested review from a team and xiangyan99 as code owners February 3, 2026 21:46
Copy link
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

This PR adds debug logging around access token cache hits in the Azure Identity internal clients to give better observability into when tokens are served from cache. It also performs minor signature formatting cleanups (trailing commas) for consistency.

Changes:

  • Introduced module-level loggers in managed_identity_client.py and aad_client_base.py and added detailed debug messages when valid cached access tokens are found (including scopes/resource, tenant, TTL, refresh timing, and cache identity).
  • Normalized some function signatures by adding trailing commas to **kwargs parameters for consistency and formatting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/identity/azure-identity/azure/identity/_internal/managed_identity_client.py Adds a module-level logger and emits a detailed debug log whenever a managed identity access token is returned from cache, including expiry, refresh timing, and cache identity.
sdk/identity/azure-identity/azure/identity/_internal/aad_client_base.py Adds a module-level logger and emits a detailed debug log on AAD cached token hits (with scopes, tenant, expiry, refresh timing, and cache identity), and updates several method signatures with trailing commas.

Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Copy link
Member

@xiangyan99 xiangyan99 left a comment

Choose a reason for hiding this comment

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

Do you want to update changelog?

@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure Identity SDK Improvements Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants