API
The methods of the PeekInside instance, and the lower-level integrations for when attach() doesn't fit.
const peekInside = PeekInside.attach(app);
peekInside.setEnabled(false); // pause recording
peekInside.report(error); // record an error (see Exceptions)
peekInside.measure('step', fn); // time some of your own code (see Timeline)
PeekInside.requestId(); // the id of the request being handled, for your logs
PeekInside.setUser({ id, email }); // who the request is for (see Exceptions)
PeekInside.job('nightly', fn); // run a background job as a recorded run (see Jobs)
peekInside.instrument(pg); // instrument a driver automatic patching can't find
await peekInside.flush(); // send everything queued (before a short-lived process exits)
peekInside.stop(); // stop recording and sending
| Method | Description |
|---|---|
PeekInside.attach(app, options) |
Attaches to an Express, Koa, Fastify, NestJS or Hono app, or an http.Server, and returns the instance. See Configuration. |
attachTo(app, options) |
Attaches an instance you created to an app, such as a NestJS worker made after PeekInside. See the quick start. |
setEnabled(enabled) |
Pauses or resumes recording |
report(error, options) |
Records an error and returns its id. See Exceptions. |
measure(name, fn) |
Runs fn and adds its duration to the request's timeline. See measuring your own code. |
PeekInside.requestId() |
The id of the request the calling code runs for, or null |
PeekInside.dump(value, label) |
Shows value in the local dashboard, under the request it was dumped in, and returns it. See Dumps. |
job(name, fn, options) |
Runs fn as a recorded job run and returns what it returns. See Jobs. |
PeekInside.setUser(user) |
Who the request being handled is for: { id, email, name, phone } or just an id. See Users. |
instrument(...drivers) |
Instruments drivers that automatic patching can't find. See bundled apps. |
flush() |
Sends everything queued; await it before a short-lived process exits |
stop() |
Stops recording and sending |
Lower-level integrations#
For when attach() doesn't fit: expressMiddleware(), koaMiddleware(), fastifyHook(fastify), wrapHttpServer(server) and intercept(req, res, next).