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.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 or Fastify app, or an http.Server, and returns the instance. See Configuration. |
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 |
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).