ExpressJs
Code Execution Monitoring for Express applications.
Install
Install the latest version using the npm command below:
Configure the Ingestion Key
You need an Ingestion Key to create an Inspector instance. Get a new one by creating a project in your Inspector dashboard.
If you use dotenv
you can configure the Inspector Ingestion Key in your environment file:
Initialization
Just two steps:
Initialize Inspector as first line of code, before you require any other modules - i.e. before
express
,http
,mysql
, etc.Attach the
expressMiddleware()
to your express app.
Send an HTTP request to your express app to see the first data in your dashboard.
Some of the most used modules will be autowired by default. Learn more about autowiring.
Exclude paths
If you want to turn off monitoring in some parts of your application you can pass a JSON object to the expressMiddleware
function with excludePaths
property to define which routes you want to exclude:
You can also use the wildcard character *
to match a subset of your urls:
Access the Inspector instance
Inspector will decorate the request instance with a new property to access Inspector anywhere in your application:
Custom Segments
By default Inspector will report many different tasks based on the application's dependencies, but you are free to "wrap" some parts of your code that you consider relevant to create a more complete picture of what statements are executed during an execution cycle and its performance.
Last updated