@financial-times/community-js-telemeter v1.5.0
@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.jsProgrammatic
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 = falseIt 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 localhostHow it works...
The instrument file monkey patches the following Node.js entities to emit events on the telemeter:
http.Serverhttps.Serverhttp.ClientRequesthttp.requesthttp.gethttps.requesthttps.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.
11 months ago
11 months ago
8 months ago
11 months ago
8 months ago
8 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago