4.4.1 • Published 10 days ago

@shopify/statsd v4.4.1

Weekly downloads
14,006
License
MIT
Repository
github
Last release
10 days ago

@shopify/statsd

Build Status Build Status License: MIT npm version

An opinionated StatsD client for Shopify Node.js servers and other StatsD utilities.

Installation

yarn add @shopify/statsd

Usage

Client

Create a StatsD client with the following:

import {StatsDClient} from '@shopify/statsd';

const statsdClient = new StatsDClient({
  host: 'some-statsd-host.com',
  port: '8125',
  prefix: 'AppName',
  suffix: 'AppSuffix',
  globalTags: {hello: 'world'},
});

distribution

Tracks the statistical distribution of a set of values across your infrastructure.

statsdClient.distribution(
  'navigationComplete',
  100, // in milliseconds
  ['navigation', 'complete', 'performance'], // user-defined tags to go with the data
);

timing

Represents the timing stat

statsdClient.timing(
  'request_duration',
  100, // in milliseconds
  [], // user-defined tags to go with the data
);

gauge

Represents the gauge stat

statsdClient.gauge(
  'my_gauge',
  123.45, // value
  [], // user-defined tags to go with the data
);

increment

Increments a stat by 1.

statsdClient.increment(
  'myCounter',
  ['navigation', 'complete', 'performance'], // user-defined tags to go with the data
);

Increment can also be supplied a value to increment the metric by.

statsdClient.increment(
  'myCounter',
  ['navigation', 'complete', 'performance'], // user-defined tags to go with the data,
  {}, // additional options
  4, // value to increment by
);

close

Close statsd client. This will ensure all stats are sent and stop statsd from doing anything more.

statsdClient.close();

childClient

Create a child client and add more context to the client. The globalTags will be merged. The prefix and suffix will be concatenated like in this example.

statsdClient.childClient({
  prefix: '.NewPrefix',
  suffix: '.NewSuffix',
  globalTags: {foo: 'bar'},
});

In this example the prefix will be AppName.NewPrefix, the suffix will be AppSuffix.NewSuffix and the globalTags will be {hello: 'world', foo: 'bar'}.

4.4.1

10 days ago

4.4.0

1 month ago

4.2.2

1 year ago

4.2.1

1 year ago

4.3.0

1 year ago

4.2.0

1 year ago

4.1.0

1 year ago

4.1.1

1 year ago

4.0.1

2 years ago

4.0.0

2 years ago

3.0.12

2 years ago

3.0.10

2 years ago

3.0.11

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

3 years ago

3.0.4

3 years ago

3.0.5

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago