Log metrics and task lifecycle events with
debug
, as a processor or publisher.
Atelemetry
plugin.
Click to expand
const telemetry = require('@telemetry-js/telemetry')()
const debug = require('@telemetry-js/plugin-debug')
telemetry.task()
.process(debug)
// And/or
.publish(debug)
This plugin can fulfill both the role of processor and publisher. In addition, it can be inserted into a task multiple times, e.g. before and after a certain processor. If you do, set a custom debug scope to differentiate the output.
For example, we can log metrics before they are summarized and when they are published:
const telemetry = require('@telemetry-js/telemetry')()
const osmem = require('@telemetry-js/collector-osmem')
const simple = require('@telemetry-js/schedule-simple')
const summarize = require('@telemetry-js/processor-summarize')
const debug = require('@telemetry-js/plugin-debug')
telemetry.task()
.collect(osmem)
.schedule(simple, { interval: '5s' })
.process(debug, { scope: 'telemetry:process'})
.process(summarize, { window: '1m' })
.publish(debug, { scope: 'telemetry:publish'})
Debug output can be enabled with the environment variable DEBUG=telemetry:*
Please see debug
for details.
Yet to document.
With npm do:
npm install @telemetry-js/plugin-debug
This project is kindly sponsored by Reason Cybersecurity Ltd.
MIT © Vincent Weevers