This package is now deprecated and will not receive any updates in the future.
A Service Client plugin for reporting operational metrics to a StatsD daemon.
const ServiceClient = require('@vrbo/service-client');
const SCStatsD = require('@vrbo/service-client-statsd');
ServiceClient.use(SCStatsD);
const client = ServiceClient.create('myservice')
(async function() {
await client.request({ method: 'GET', path: '/v1/test/endpoint', operation: 'foobar' })
/**
* Outputs metrics to StatsD daemon:
* localhost.serviceclient.myservice.foobar.statusCode200 method=increment
* localhost.serviceclient.myservice.foobar.statusCode2xx method=increment
* localhost.serviceclient.myservice.foobar.total method=timing value=1
*/
})()
See plugin documentation for more usage information.
- hostname - The hostname used to initialize the internal instance of Lynx. Defaults to
'localhost'
. - port - The port used to initialize the internal instance of Lynx. Defaults to
8125
. - tcp - Whether or not to transmit stats via TCP. Defaults to
false
. - lynxOptions - Additional configuration options used to initilize the internal instance of Lynx.
- transmit - A boolean indicating whether or not to actually send these metrics to the Lynx instance. Defaults to
true
. - prefix - An optional value to prepend to the beginning of the metrics key reported to StatsD.
Example:
const client = ServiceClient.create('myservice', {
plugins: {
statsd: {
// options here
}
}
})
This package uses debug
for logging debug statements.
Use the serviceclient:plugin:statsd
namespace to log related information:
DEBUG=serviceclient:plugin:statsd npm test