Guides

Observability

A predictive cache is only worth running if you can see what it's doing. Glacier exposes the numbers that matter and streams events you can pipe anywhere.


The metrics that matter

const stats = glacier.stats()
// {
//   hitRate: 0.91,            // requests served from warm cache
//   predictionAccuracy: 0.78, // warmed entries that were actually used
//   wasteRatio: 0.06,         // warmed-but-unused fetches
//   p50, p95                  // latency, warm vs. cold
// }
  • Hit rate is the headline number — how often users got an instant response.
  • Prediction accuracy tells you whether Glacier is warming the right things.
  • Waste ratio is the cost side: warmed entries that expired unused. Keep an eye on it when you lower the confidence threshold.

Events

Subscribe to the event stream for per-entry visibility:

glacier.on('hit', ({ key, source }) => metrics.inc('glacier.hit', { source }))
glacier.on('miss', ({ key }) => metrics.inc('glacier.miss'))
glacier.on('warm', ({ key, confidence }) => log.debug('warmed', key, confidence))

OpenTelemetry

Glacier ships an OpenTelemetry exporter. Register it once and hit rate, accuracy, and latency show up alongside the rest of your traces:

import { otelExporter } from '@glacier/otel'
glacier.use(otelExporter())

Debug mode

Set debug: true in the config to log every prediction and the signals behind it. It's verbose — use it locally while tuning, not in production.

Next: Testing for keeping Glacier deterministic in CI.

Previous
Framework adapters