Claude-skill-registry cache-observability

Track cache hit rates, latency, and detect cache-related issues

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/cache-observability" ~/.claude/skills/majiayu000-claude-skill-registry-cache-observability && rm -rf "$T"
manifest: skills/data/cache-observability/SKILL.md
source content

Cache Observability

Cache is performance-critical. Track hit rate, latency, and evictions.

Key Metrics

MetricTypeDescription
cache.hits
CounterSuccessful reads
cache.misses
CounterReads that missed
cache.gets.duration
HistogramGET latency
cache.evictions
CounterKeys evicted
cache.memory.used
GaugeMemory consumption

Span Attributes

AttributeExampleRequired
cache.system
redis, memcachedYes
cache.operation
GET, SETYes
cache.hit
true/falseYes
cache.key_prefix
user:*Recommended (not full key!)

Hit Rate

hit_rate = cache.hits / (cache.hits + cache.misses)
  • Good: >90%
  • Concerning: <80% → Check TTL, warming strategy

Issues to Detect

IssueDetectionFix
Low hit rate<80%Tune TTL, warm cache
Cache stampedeMany misses for same keyDistributed locks
High latencyp99 >10msCheck network, value size
Memory pressurememory >90% of maxEviction policy, sizing

Cache Wrapper Pattern

Before GET: Start timer
After GET:  Record duration, increment hits or misses, set cache.hit on span

Anti-Patterns

  • Full keys in metrics → High cardinality, use prefix only
  • No eviction monitoring → Can't detect memory pressure
  • Ignoring serialization time → Track total time including marshal

References

  • references/platforms/{platform}/cache.md