Skip to content

feat(metrics): rate-limit snapshot cache metrics on shared hosts#108

Merged
khaile merged 3 commits into
mainfrom
feature/cap-112-sc-impl-04-rate-limit-snapshot-cache-metrics-on-shared-hosts
Jul 3, 2026
Merged

feat(metrics): rate-limit snapshot cache metrics on shared hosts#108
khaile merged 3 commits into
mainfrom
feature/cap-112-sc-impl-04-rate-limit-snapshot-cache-metrics-on-shared-hosts

Conversation

@khaile

@khaile khaile commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Implements SC-IMPL-04 (CAP-112): Rate-limit snapshot cache metrics on shared hosts.

Changes

  • Add set_metric_redaction/is_metric_redaction_enabled to capsule-core metrics module
  • Add rate-limited record_snapshot_cache_hit, record_snapshot_cache_miss, record_snapshot_eviction functions
  • Wire up metric emission in TieredCacheManager::lookup() (hits/misses) and CacheTierStore::evict() (evictions)
  • Connect host-agent shared_host_metric_redaction flag to capsule-core metrics

Behavior

  • Dedicated-tenancy hosts: Full per-host granularity maintained (no rate-limiting)
  • Shared multi-tenant hosts: Metrics rate-limited to 60s intervals per key, with optional tenant_id label when available

Metrics affected

  • capsule_snapshot_cache_hits
  • capsule_snapshot_cache_misses
  • capsule_snapshot_eviction_count
  • capsule_snapshot_eviction_bytes

Testing

  • 15 new unit tests for rate-limiting behavior
  • All existing cache_tiering tests pass (47 tests)
  • cargo clippy --all-targets --all-features --locked -- -D warnings passes

Closes CAP-112

…-112)

Add rate-limiting infrastructure to snapshot cache metrics
(capsule_snapshot_cache_hits, capsule_snapshot_cache_misses,
capsule_snapshot_eviction_count, capsule_snapshot_eviction_bytes)
when the host is configured for shared multi-tenancy.

Changes:
- Add set_metric_redaction/is_metric_redaction_enabled to capsule-core
- Add rate-limited record_snapshot_cache_hit/miss/eviction functions
  using parking_lot::Mutex (no poisoning, faster fast path)
- Wire up metric emission in TieredCacheManager::lookup and evict
- Connect host-agent shared_host_metric_redaction flag to capsule-core
- Document host-level aggregation limitation (tenant context not yet
  available in the cache tiering layer)

On dedicated-tenancy hosts, full per-host granularity is maintained.
On shared hosts, metrics are rate-limited to 60s intervals per key.

Closes CAP-112
@khaile khaile force-pushed the feature/cap-112-sc-impl-04-rate-limit-snapshot-cache-metrics-on-shared-hosts branch from c605a99 to 0c49f4b Compare July 2, 2026 11:43
khaile added 2 commits July 2, 2026 19:29
Update AGENTS.md with guidelines for hashbrown and parking_lot.
@khaile khaile merged commit 4e41a4b into main Jul 3, 2026
12 checks passed
@khaile khaile deleted the feature/cap-112-sc-impl-04-rate-limit-snapshot-cache-metrics-on-shared-hosts branch July 3, 2026 07:17
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