1.3.1 • Published 6 months ago

@financial-times/community-js-telemeter v1.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

@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.

1.3.1

6 months ago

1.2.2

8 months ago

1.3.0

6 months ago

1.3.0-alpha.227.1

6 months ago

1.3.0-alpha.227.0

6 months ago

1.3.1-alpha.0

6 months ago

1.2.2-alpha.215.1

8 months ago

1.2.2-alpha.215.0

8 months ago

1.2.0

1 year ago

1.2.1

1 year ago

1.2.1-alpha.0

1 year ago

1.1.0

1 year ago

1.1.0-alpha.0

1 year ago

1.0.0

1 year ago

1.0.0-alpha.3

1 year ago

1.0.0-alpha.2

1 year ago

1.0.0-alpha.1

1 year ago

1.0.0-alpha.0

1 year ago

0.3.0-alpha.1

1 year ago

0.3.0-alpha.0

1 year ago

0.2.0

1 year ago

0.2.0-alpha.0

1 year ago

0.1.0

1 year ago

0.1.0-alpha.0

1 year ago