@vrbo/service-client-statsd

A Service Client plugin for reporting operational metrics to a StatsD daemon

Usage no npm install needed!

<script type="module">
  import vrboServiceClientStatsd from 'https://cdn.skypack.dev/@vrbo/service-client-statsd';
</script>

README

@vrbo/service-client-statsd

NPM Version Dependency Status NPM Downloads

A Service Client plugin for reporting operational metrics to a StatsD daemon.

Contents

Usage

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.

Configuration Options

  • 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
        }
    }
})

Development

This package uses debug for logging debug statements.

Use the serviceclient:plugin:statsd namespace to log related information:

DEBUG=serviceclient:plugin:statsd npm test

Further Reading