You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(telemetry): add cache hit rate metric across all cache systems (#638)
## Summary
- Add `recordCacheHit()` helper that emits `cache.hit_rate` distribution
metric (0=miss, 100=hit) with `cache_name` attribute
- Instrument all 5 cache systems: dsn, dsn-detection, project, region,
project-root, http
- Update dashboard "Cache Hit Rate (%)" widget to use tracemetrics avg
grouped by cache_name
## Why
Sentry dashboards don't support division/formula widgets, so computing
`hits / total` isn't possible. By emitting 0 for miss and 100 for hit as
a distribution metric, `avg(value,cache.hit_rate,distribution,none)`
directly gives the hit rate percentage.
## Caches instrumented
| Cache name | Function | What it caches |
|---|---|---|
| `dsn` | `getCachedDsn()` | Single-DSN detection result per directory |
| `dsn-detection` | `getCachedDetection()` | Full detection with mtime
validation |
| `project` | `getByKey()` | Project info by orgId:projectId or DSN key
|
| `region` | `getOrgRegion()` | Org-to-region URL mapping |
| `project-root` | `getCachedProjectRoot()` | cwd-to-project-root
mapping |
| `http` | `getCachedResponse()` | HTTP response cache (also has
existing cache.hit span attribute) |
0 commit comments