start here
Getting started
api
API reference
Complete reference
API reference
All exports, types, and options. The canonical machine-readable reference.
Function
withLatency(fn, profile)
Wrap a single async function. Full parameter docs, TypeScript signature, and examples.
Function
withLatencyAll(client, profile)
Wrap every async method on a client object at once.
Reference
Built-in presets
p50/p95/p99 and error rates for postgres, redis, openai, stripe, and 6 more.
guides
Usage patterns
Testing
Deterministic testing
Make tests reproducible by seeding Math.random or mocking the wrapper entirely.
Patterns
Best practices
Where to wrap, how to test failures, and how to avoid common mistakes.
Safety
Production usage
Conditional wrap patterns — NODE_ENV, env vars, and the maybeSlowDep helper.