Skip to content

Fix MemoryCache OTEL size units and improve tag name - #133151

Merged
cincuranet merged 3 commits into
dotnet:mainfrom
cincuranet:memorycache-otel-polish
Sep 3, 2026
Merged

Fix MemoryCache OTEL size units and improve tag name#133151
cincuranet merged 3 commits into
dotnet:mainfrom
cincuranet:memorycache-otel-polish

Conversation

@cincuranet

@cincuranet cincuranet commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Copilot AI lite review requested due to automatic review settings September 3, 2026 07:15
@cincuranet
cincuranet requested review from svick and removed request for Copilot September 3, 2026 07:15
@cincuranet
cincuranet requested a lite review from Copilot September 3, 2026 07:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-caching
See info in area-owners.md if you want to be subscribed.

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.

🟡 Changes recommended

The estimated-size metric’s updated OTEL unit/description isn’t covered by tests, so the contract could regress without detection.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates Microsoft.Extensions.Caching.Memory OpenTelemetry metric metadata to better match current semantic conventions: it renames the cache-request outcome tag and corrects the unit/description for the cache’s estimated size metric to reflect that MemoryCache sizes are application-defined units, not bytes.

Changes:

  • Renamed the dotnet.cache.requests tag key from dotnet.cache.request.type to dotnet.cache.request.result for hit/miss.
  • Updated dotnet.cache.estimated_size unit from "By" to "1" and clarified the description to indicate application-defined units.
  • Updated metrics tests to validate the new request-result tag key (and should be extended to validate estimated-size metadata).
File summaries
File Description
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs Updates OTel tag key for requests and fixes estimated-size unit/description to non-bytes semantics.
src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheMetricsTests.cs Updates assertions to expect the new request-result tag key.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

@cincuranet
cincuranet merged commit 4878f22 into dotnet:main Sep 3, 2026
81 of 84 checks passed
@cincuranet
cincuranet deleted the memorycache-otel-polish branch September 3, 2026 11:13
@cincuranet

Copy link
Copy Markdown
Contributor Author

/backport to release/11.0

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

mrek-msft pushed a commit that referenced this pull request Sep 3, 2026
…133157)

Backport of #133151 to release/11.0

/cc @cincuranet

## Customer Impact

- [ ] Customer reported
- [x] Found internally

## Regression

- [ ] Yes
- [x] No

## Testing

Verified by tests.

## Risk

Low. New feature in 11 and only change in OTEL names/identifiers.

Co-authored-by: Jiri Cincura ↹ <jiri@cincura.net>
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants