Tracing an ExpressJS Application provides two levels of tracing: basic tracing and function-level tracing

Basic tracing collects request, response and error information, logs and provides a timeline of external resource access (databases, http endpoints, external services) of your unit (basically, endpoint or handler).

Function-level tracing also adds timings of the individual function calls to the timeline.

Setting up a Basic Tracing#

1. Install client library#

yarn add


npm i --save

2. Wrap your express application with tracing#

import { traceExpress, tracer, captureConsoleLogs } from ''
import express from 'express'
const app = express()
const port = 3000
app.get('/trace-http-request', async (req, res) => {
const fact = await catFactsService.getFact()

Note the captureConsoleLogs() call which will automatically collect console.log logs for your trace.

3. Add tracer.setUnitName calls inside your handlers with appropriate names of your handlers.#

4. Set the RECAP_DEV_SYNC_ENDPOINT environment variable to point at your server's sync endpoint, for example:#

Check out an example project here.

Setting up a Function-level Tracing#

Click here to learn how to set up the function-level tracing for your application.