Fix MemoryCache OTEL size units and improve tag name - #133151
Conversation
|
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. |
|
Tagging subscribers to this area: @dotnet/area-extensions-caching |
There was a problem hiding this comment.
🟡 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.requeststag key fromdotnet.cache.request.typetodotnet.cache.request.resultforhit/miss. - Updated
dotnet.cache.estimated_sizeunit 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
|
/backport to release/11.0 |
|
Started backporting to |
…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>
Follow up from open-telemetry/semantic-conventions#4068 and #126451.