Repository navigation
Reduce allocations when building OpenTelemetry metric tags - #6227
Merged
Sergei Smelov (ssmelov) merged 2 commits intoOct 23, 2026
Merged
Sergei Smelov (ssmelov) merged 2 commits into
Sergei Smelov (ssmelov) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactor preserves canonical metric values and collision protection, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Reduces allocations in MSAL.NET’s OpenTelemetry metric tag construction.
Changes:
- Builds tags directly in
TagList, removing intermediate arrays and lists. - Caches canonical tag keys per metric instead of creating a
HashSetfor each recording. - Retains canonical-tag validation and collision protection.
| File | Description |
|---|---|
| src/​client/​Microsoft.Identity.Client/​Platforms/​Features/​OpenTelemetry/​OtelInstrumentation.cs | Uses direct tag construction and cached canonical keys across metric recording paths. |
Review effort: Balanced
Neha Bhargava (neha-bhargava)
approved these changes
Oct 22, 2026
Bogdan Gavril (bgavrilMS)
approved these changes
Oct 23, 2026
Sergei Smelov (ssmelov)
deleted the
ssmelov/reduce-allocations-when-building-otel-metric-tags
branch
October 23, 2026 14:59
This was referenced Oct 29, 2026
Closed
Merged
fix: Bump Microsoft.Identity.Client from 4.91.1 to 4.92.0
Halceyon/open-telemetry-trace-listener#426
Merged
This was referenced Nov 12, 2026
Merged
maksii
pushed a commit
to maksii/paqvilo
that referenced
this pull request
Nov 16, 2026
Updated [Microsoft.Identity.Client](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) from 4.91.1 to 4.92.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Client's releases](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/releases)._ ## 4.92.0 ### New Features - Added `COSMIC_LOCATION` as a regional auto-detection source, after `REGION_NAME` and before IMDS. [#​6240](AzureAD/microsoft-authentication-library-for-dotnet#6240) - Added `ITokenCacheSnapshotProvider` and `TokenCacheSnapshot` for process-local token-cache capture and restore without repeated JSON serialization. Use V3 serialization for persistence. [#​6229](AzureAD/microsoft-authentication-library-for-dotnet#6229) ### Bug Fixes - Fixed certificate private-key attachment on .NET Framework 4.7.2 to support non-exportable CNG keys. [#​6244](AzureAD/microsoft-authentication-library-for-dotnet#6244) - Fixed managed identity KeyGuard attestation endpoint selection to use cloud-specific regional endpoints from IMDS compute metadata. [#​6238](AzureAD/microsoft-authentication-library-for-dotnet#6238) - Fixed Android broker request serialization by registering `BrokerRequest` in the source-generated JSON serializer context. [#​6226](AzureAD/microsoft-authentication-library-for-dotnet#6226) ### Changes - Updated `Microsoft.Identity.Client.NativeInterop` from 0.20.6 to 0.20.7. [#​6230](AzureAD/microsoft-authentication-library-for-dotnet#6230) - Reduced OpenTelemetry metric-tag allocations using `TagList` and cached canonical tag-key sets. Custom enrichers should use noncanonical tag names. [#​6227](AzureAD/microsoft-authentication-library-for-dotnet#6227) Commits viewable in [compare view](AzureAD/microsoft-authentication-library-for-dotnet@4.91.1...4.92.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 16, 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.
Optimizes OpenTelemetry tag construction by removing per-recording canonical-tag arrays and HashSet allocations.