Skip to content

fix(decorators): async miss-store records carry serializer/hit like sync (LAB-3755) - #295

Open
27Bslash6 wants to merge 1 commit into
mainfrom
agent/winston/8b2492eb4de8
Open

27Bslash6 wants to merge 1 commit into
mainfrom
agent/winston/8b2492eb4de8

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a metrics labeling inconsistency between the async and sync cache decorator wrappers when recording cache miss-store operations (LAB-3755).

Problem

The sync wrapper records its miss-store operation with serializer="rust" and hit=False labels. However, the async wrapper's two miss-store sites (the distributed-lock path and the no-lock fallback path) were recording the set operation without these labels. As a result, the Prometheus sink filed async set operations under serializer="unknown" with no hit marker, producing inconsistent metrics between sync and async code paths.

Changes

  • src/cachekit/decorators/wrapper.py: Added the serializer="rust" and hit=False labels to both async miss-store recording sites (locked and no-lock fallback), bringing them into parity with the sync wrapper.

  • tests/unit/test_async_set_record_labels.py: Added a new test that pins both async miss-store paths through the real decorator stack. It uses two byte-store backends:

    • _ByteStore (no acquire_lock) to drive the no-lock miss path
    • _LockableByteStore (with acquire_lock) to drive the locked miss path

    The test verifies that after a cache miss reaches L2, exactly one set record is produced carrying serializer="rust" and hit=False, matching the sync behavior.

Impact

Async cache set operations will now be correctly labeled in metrics/telemetry, ensuring consistent observability across sync and async cache usage.

…ync (LAB-3755)

The sync wrapper's miss-store record passes serializer="rust" and hit=False.
The two async miss-store sites (locked path and no-lock fallback) passed
neither, so the collector took its serializer default and Prometheus filed
every async set under cache_operations_total{serializer="unknown"} while sync
sets landed under "rust". Same operation, two label values, split series.

Both async sites now pass the same two keywords as the sync site. A unit test
drives an async miss through both paths via the real decorator stack (a
backend with acquire_lock selects the locked path) and asserts the record the
wrapper emits.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: ec85cf73-68d0-433d-b5be-da96d944fa0f

📥 Commits

Reviewing files that changed from the base of the PR and between 284fa7e and aac41a9.

📒 Files selected for processing (2)
  • src/cachekit/decorators/wrapper.py
  • tests/unit/test_async_set_record_labels.py

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


Walkthrough

Changes

Async cache-set metric labels

Layer / File(s) Summary
Metric labels and coverage
src/cachekit/decorators/wrapper.py, tests/unit/test_async_set_record_labels.py
The locked and unlocked async cache-set paths now record serializer="rust" and hit=False. Parametrised tests cover both paths and verify one set record per miss-store operation.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to aac41

The async cache-set metric-label correction is covered for both execution paths and presents no current merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the async miss-store metric fix and its parity with the synchronous path. It is concise and specific.
Description check ✅ Passed The description explains the change, motivation, type, security impact, documentation decision, tests, results, and backward compatibility. It does not include the optional Additional Notes section an…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/winston/8b2492eb4de8

Comment @coderabbitai help to get the list of available commands.

@kodus-27b

kodus-27b Bot commented Sep 16, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant