Skip to content

Add MSAL.NET telemetry enrichment#6071

Merged
neha-bhargava merged 8 commits into
mainfrom
ssmelov/add_msal_telemetry_enrichment
Jun 18, 2026
Merged

Add MSAL.NET telemetry enrichment#6071
neha-bhargava merged 8 commits into
mainfrom
ssmelov/add_msal_telemetry_enrichment

Conversation

@ssmelov

@ssmelov ssmelov commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This PR proposes an extensibility mechanism to enrich existing MSAL OpenTelemetry metrics with additional dimensions, without changing or replacing MSAL’s canonical metric set.

@ssmelov ssmelov requested a review from a team as a code owner June 17, 2026 20:57
Copilot AI review requested due to automatic review settings June 17, 2026 20:57

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 adds a per-request extensibility hook (WithOtelTagsEnricher) that lets callers enrich MSAL’s existing OpenTelemetry metrics with additional tags, while also surfacing an ExecutionResult to the enricher for success/failure context.

Changes:

  • Introduces a new public fluent API WithOtelTagsEnricher(...) and plumbs the delegate through request parameters.
  • Extends OpenTelemetry instrumentation plumbing to pass ExecutionResult + enricher into success/failure metric recording paths (foreground + proactive background refresh).
  • Adds unit tests validating tag enrichment on success/failure and resilience when the enricher throws.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Microsoft.Identity.Test.Unit/TelemetryTests/OTelInstrumentationTests.cs Adds coverage for success/failure enrichment and enricher-throws behavior.
src/client/Microsoft.Identity.Client/TelemetryCore/OpenTelemetry/IOtelInstrumentation.cs Extends internal OTel interface to accept ExecutionResult and tag enricher.
src/client/Microsoft.Identity.Client/TelemetryCore/OpenTelemetry/NullOtelInstrumentation.cs Updates no-op instrumentation implementation to match new OTel signatures.
src/client/Microsoft.Identity.Client/Platforms/Features/OpenTelemetry/OtelInstrumentation.cs Implements tag enrichment by applying caller-provided tags during metric recording.
src/client/Microsoft.Identity.Client/Internal/Requests/RequestBase.cs Creates/passes ExecutionResult + enricher into OTel success/failure telemetry.
src/client/Microsoft.Identity.Client/Internal/Requests/SilentRequestHelper.cs Propagates enricher into proactive refresh telemetry (success + failure).
src/client/Microsoft.Identity.Client/Internal/Requests/Silent/CacheSilentStrategy.cs Passes enricher into background refresh helper.
src/client/Microsoft.Identity.Client/Internal/Requests/OnBehalfOfRequest.cs Passes enricher into background refresh helper.
src/client/Microsoft.Identity.Client/Internal/Requests/ManagedIdentityAuthRequest.cs Passes enricher into background refresh helper.
src/client/Microsoft.Identity.Client/Internal/Requests/ClientCredentialRequest.cs Passes enricher into background refresh helper.
src/client/Microsoft.Identity.Client/Internal/Requests/AuthenticationRequestParameters.cs Exposes the configured enricher from common parameters.
src/client/Microsoft.Identity.Client/ApiConfig/Parameters/AcquireTokenCommonParameters.cs Stores the enricher delegate on common request parameters.
src/client/Microsoft.Identity.Client/Extensibility/AbstractConfidentialClientAcquireTokenParameterBuilderExtension.cs Adds the new public WithOtelTagsEnricher(...) extension method.
src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Unshipped.txt Declares the new public API surface for netstandard2.0.
src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Unshipped.txt Declares the new public API surface for net8.0.
src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Unshipped.txt Declares the new public API surface for net8.0-ios.
src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Unshipped.txt Declares the new public API surface for net8.0-android.
src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Unshipped.txt Declares the new public API surface for net472.
src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Unshipped.txt Declares the new public API surface for net462.

Copilot AI review requested due to automatic review settings June 18, 2026 20:29

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

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

Copilot AI review requested due to automatic review settings June 18, 2026 21:52

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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

@neha-bhargava neha-bhargava 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.

Looks good. Thanks for your contributions!

Copilot AI review requested due to automatic review settings June 18, 2026 22: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.

Pull request overview

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

@neha-bhargava neha-bhargava merged commit 843ad43 into main Jun 18, 2026
16 checks passed
@neha-bhargava neha-bhargava deleted the ssmelov/add_msal_telemetry_enrichment branch June 18, 2026 23:30
This was referenced Jun 24, 2026
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.

4 participants