Caching: opt-in per-key read attribution (port of ServiceCommon #1862 + #1869)#37
Merged
Merged
Conversation
… visibility Port of UiPath/ServiceCommon #1862 + #1869. Once GET+TTL reads bundle into one MULTI/EXEC transaction the individual keys no longer reach the wire, so per-key read attribution is recovered at the cache layer instead of giving back the batching win. - Hit/miss metric (Caching.Stats.Hits/Misses) is emitted once per operation with a Keys dimension (batch is a hit if any key hit); every hit/miss metric carries Keys (1 for single/non-read ops) so the dimension is consistent. - Opt-in RedisCacheOptions.KeyReadTelemetryEnabled (default false): read paths emit a per-key Redis dependency (key in data, hit/miss via resultCode, success always true, a BatchId shared per operation). RedisHashCache emits one dependency per hash key, never per field. The dependency start time is captured at Start(), not at emit time. - ITelemetryOperation gains Track(bool, int) and TrackKeyReads((string,bool)[]); shared TrackRead on RedisCacheBase. Hit/miss honors InterpretReadResult / ICacheEntry.Found semantics; disconnected reads short-circuit without telemetry; partial MGET/HMGET results and per-key sub-task failures degrade to whole-batch miss. Tests + CHANGELOG + docs (settings reference, telemetry how-to) updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
cosmin-staicu
requested review from
alinahornet,
cosminvlad,
litheon,
lucianaparaschivei and
razvalex
as code owners
June 25, 2026 16:20
- RedisHashCacheTests: hoist the constant {"f1","f2"} field array to a static
readonly field (CA1861).
- TelemetryOperationTests: pass TestContext.Current.CancellationToken to
Task.Delay (xUnit1051).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
|
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.



Port from
UiPath/ServiceCommonof the per-key read telemetry work: #1862 (feature) and #1869 (dependency start-time fix + docs), combined into one PR since the OSS repo has neither yet and #1869 builds on #1862.Why
Batched reads (
MGET+ TTL, and the hash value+TTL read) bundle into a singleMULTI/EXECtransaction, so the individual keys no longer reach the wire and the Redis profiler/instrumentation can't report which keys are read. Attribution is recovered at the cache layer.What
Keysdimension (batch = hit if any key hit). Every hit/miss metric carriesKeys(1for single/non-read ops) so the dimension is consistent across the metric name.RedisCacheOptions.KeyReadTelemetryEnabled(defaultfalse): read paths emit a per-keyRedisdependency (key indata, hit/miss viaresultCode,successalwaystrue, aBatchIdshared per operation for correlation).RedisHashCacheemits one dependency per hash key, never per field. The dependencystartTimeis captured atStart(), not at emit time.ITelemetryOperationgainsTrack(bool hit, int keyCount)andTrackKeyReads((string Key, bool Hit)[] reads)(sharedTrackReadonRedisCacheBase). Hit/miss honorsInterpretReadResult/ICacheEntry.Found; disconnected reads short-circuit without telemetry; partialMGET/HMGETresults and per-key sub-task failures degrade to a whole-batch miss.Tests, CHANGELOG, and docs (settings reference + telemetry how-to) updated. Suite green: 1116/1116 on net8.0 and net10.0.
🤖 Generated with Claude Code