1.0.4 • Published 6 years ago
statsd-http-client v1.0.4
StatsD HTTP Client
StatsD HTTP client with REST interface for using in browsers.
Installation
$ npm install statsd-http-clientUsage
All initialization parameters are optional.
Parameters (specified as an options hash):
scheme: The scheme of addressdefault: httpaddress: The address to send stats todefault: ''. Example: mysite.com. Address has higher priority than host:port.host: The host to send stats todefault: 127.0.0.1port: The port to send stats todefault: 9876prefix: What to prefix each stat name withdefault: ''suffix: What to suffix each stat name withdefault: ''useDebounce: Use debounce for gather batches?default: truedebounceTime: Debounce time in msdefault: 1000token: JWT token secretdefault: none
import { Config, StatsD } from 'statsd-http-client';
const config: Config = {...};
const client = new StatsD(config);
// Increment: Increments a stat by a value (default is 1). Negative numbers converts to positive.
client.increment('name', 3);
// Decrement: Decrement a stat by a value (default is -1). Positive numbers converts to negative.
client.decrement('name', -2);
// Gauge: Gauge a stat by a specified amount (default is 1). Negative numbers converts to positive.
client.gauge('name', 5);
// Shift: Shift a stat by a specified amount (default is -1). Positive numbers converts to negative.
client.shift('name', 4);
// Timing: sends a timing command with the specified milliseconds. Negative numbers converts to positive.
client.timing('name', 500);
// Set: Counts unique occurrences of a stat (alias of unique) (default is 1).
client.set('name', 20);