Express Middleware tracking for Microsoft Application Insights SDK for Node.js.
This repository provides Express Middleware tracking for the Application Insights SDK for Node.js by monkey patching Express and the Application Insights SDK.
Note: This package is currently a WIP and likely to have bugs - please raise issues for anything you find. Please don't use in Production!
Install this package using npm / yarn.
yarn add applicationinsights-express-middleware
In your application code, require this package before Express and Application Insights:
;const appInsights = ;const express = ;...
Or alternatively, use it instead of Application Insights:
const appInsights = ;const express = ;...
You can enable the auto-collection of Express middleware data by calling
setAutoCollectExpressMiddleware(true) while configuring Application Insights:
appInsights// Use with or without the other chained auto-collection configuration methods.start;
The default for the Express middleware auto-collection is
false, so not calling this method (and calling it with
false) will result in the Express middleware not being instrumented.
If you set the value to
true, then the once the Application Insights
start() method is invoked, the package will then automatically invoke
trackDependency() whenever Express middleware is executed.
Please note that the package currently does not support the
dispose() method and therefore will not stop instrumenting Express until application restart.
Dependency Tracking Data
The Express middleware data that is sent to Application Insights is of the following form:
||The Express path associated with the middleware being executed.|
||The request method and Express path followed by the middleware function's name, or
||The error passed to the middleware function's
||The duration of time taken to execute the middleware function in milliseconds.|
||The datetime when the middleware function was invoked.|
yarn install --frozen-lockfile
Please check out the CONTRIBUTING docs.
Please check out the CHANGELOG docs.