@financial-times/community-js-telemeter v1.3.1
@financial-times/community-js-telemeter
Provides instrumentation for Node.js telemetry for community team projects.
Usage
Via --require
This module is used via the node cli --require, -r
flag which preloads the instrumentation before any other files are
loaded.
node -r @financial-times/community-js-telemeter/instrument ./my-file.js
Programmatic
The module itself exports an instance of its 'telemeter', which is an EventEmitter. This can be used to add custom behaviour responding to telemetry events.
const {telemeter} = require('@financial-times/community-js-telemeter');
telemeter.on('server:request', (request, response) => {/*...*/}
By default, the telemeter will emit logs on server requests and responses, this can be disabled if desired.
const {telemeter} = require('@financial-times/community-js-telemeter');
telemeter.serverLogging = false
It is also possible to disable telemetry on a per url basis using a regex, the example below shows the default values.
const {telemeter} = require('@financial-times/community-js-telemeter');
telemeter.serverIgnoreRegex = /^\/__/ // Ignore requests on paths starting with double underscore
telemeter.clientIgnoreRegex = /^https?:\/\/localhost(:[0-9]+)?(\/|$)/ // Ignore request to localhost
How it works...
The instrument file monkey patches the following Node.js entities to emit events on the telemeter:
http.Server
https.Server
http.ClientRequest
http.request
http.get
https.request
https.get
For http.Server
and https.Server
it also adds a correlationId
to logs emanating from a request's synchronous and
asynchronous execution, using either the request's x-correlation-id
header if present, or a freshly generated uuid.
6 months ago
8 months ago
6 months ago
6 months ago
6 months ago
6 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago