Problem
The cache only logs Connected / Exception (src/NatsDistributedCache/NatsCache.Log.cs). There's no hit-ratio, latency, or error instrumentation, which makes production cache effectiveness hard to observe.
Investigation
Neither IDistributedCache nor (per the current Microsoft caching docs) HybridCache emits documented cache metrics for the backend store. Instrumenting at this layer is therefore genuinely additive and benefits both direct IDistributedCache consumers and HybridCache-L2 users. FusionCache's *.OpenTelemetry package is good prior art for the shape.
Proposal
Add first-class telemetry using System.Diagnostics (no hard OpenTelemetry dependency):
- A named
Meter with: get/set/remove/refresh counters, a hit/miss counter, an operation-duration histogram, and an error counter.
- A named
ActivitySource for spans around KV operations.
- Documented
MeterName / ActivitySourceName constants and OTel-aligned tags so users can wire metrics.AddMeter(...) / tracing.AddSource(...).
Acceptance criteria
- Hit/miss/latency/error instruments emitted for cache operations.
- Public, documented meter/source names.
- Opt-in; no telemetry overhead when not subscribed.
Problem
The cache only logs
Connected/Exception(src/NatsDistributedCache/NatsCache.Log.cs). There's no hit-ratio, latency, or error instrumentation, which makes production cache effectiveness hard to observe.Investigation
Neither
IDistributedCachenor (per the current Microsoft caching docs)HybridCacheemits documented cache metrics for the backend store. Instrumenting at this layer is therefore genuinely additive and benefits both directIDistributedCacheconsumers and HybridCache-L2 users. FusionCache's*.OpenTelemetrypackage is good prior art for the shape.Proposal
Add first-class telemetry using
System.Diagnostics(no hard OpenTelemetry dependency):Meterwith: get/set/remove/refresh counters, a hit/miss counter, an operation-duration histogram, and an error counter.ActivitySourcefor spans around KV operations.MeterName/ActivitySourceNameconstants and OTel-aligned tags so users can wiremetrics.AddMeter(...)/tracing.AddSource(...).Acceptance criteria