StatsD
Extends:
StatsD Client
Constructor Summary
Public Constructor | ||
public |
constructor(options: object) |
Method Summary
Public Methods | ||
public |
asyncTimer(func: function, stat: string | string[], sampleRate: number, tags: string[] | object, callback: function): * Decorates an async function with timing recording behaviour. |
|
public |
check(name: string, status: number, options: object, tags: string[] | object, callback: function): * Send a service check |
|
public |
childClient(options: object): * Creates a child client that adds prefix, suffix and/or tags to this client. |
|
public |
decrement(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Decrements a stat by a specified amount |
|
public |
distribution(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Represents the distribution stat |
|
public |
Send on an event |
|
public |
gauge(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Gauges a stat by a specified amount |
|
public |
histogram(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Represents the histogram stat |
|
public |
increment(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Increments a stat by a specified amount |
|
public |
set(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Counts unique values by a specified amount |
|
public |
timer(func: function, stat: string | string[], sampleRate: number, tags: string[] | object, callback: function): * Represents the timing stat by recording the duration a function takes to run (in milliseconds) |
|
public |
timing(stat: string | string[], time: number, sampleRate: number, tags: string[] | object, callback: function) Represents the timing stat |
|
public |
unique(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) Counts unique values by a specified amount |
Public Constructors
public constructor(options: object) source
Params:
Name | Type | Attribute | Description |
options | object | The options to use for the client. |
|
options.host | string | The host to send metrics to. Required for TCP and UDP protocols. |
|
options.port | number | The port that StatsD is listening on. Required for TCP and UDP protocols. |
|
options.path | string | The UDS path to connect to. Required for UNIX_DGRAM protocol. |
|
options.prefix | string | Global prefix string to append to all stats. Optional |
|
options.suffix | string | Global suffix string to append to all stats. Optional |
|
options.globalize | boolean | Assigns the client to a global instance. Optional |
|
options.cacheDns | boolean | Whether or not to cache the DNS for subsequent requests. Optional |
|
options.mock | boolean | Whether or not to mock the client. Optional |
|
options.globalTags | string[] | object | Tags to include for every metroc. Optional |
|
options.maxBufferSize | number | The maximum size of the in-memory buffer. Optional |
|
options.bufferFlushInterval | number | How often the buffer is sent to StatsD. Optional |
|
options.telegraf | boolean | Flag to indicate telegraf support. Optional |
|
option.sampleRate | number | The sample rate to use fo stats. Optional |
|
options.protocol | string | The protocol to use for sending stats. Optional |
Public Methods
public asyncTimer(func: function, stat: string | string[], sampleRate: number, tags: string[] | object, callback: function): * source
Decorates an async function with timing recording behaviour.
This version of timer
will record the time take for the asyncronus action returned by func
not just the execution time of func
itself.
Params:
Name | Type | Attribute | Description |
func | function | The function to run |
|
stat | string | string[] | The stat(s) to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
Return:
* |
public check(name: string, status: number, options: object, tags: string[] | object, callback: function): * source
Send a service check
Params:
Name | Type | Attribute | Description |
name | string | The name of the service check |
|
status | number | The status of the service check (0 to 3). |
|
options | object | Additional options |
|
options.date_happened | Date | Assign a timestamp to the event. Default is now. |
|
options.hostname | string | Assign a hostname to the check. |
|
options.message | string | Assign a message to the check. |
|
tags | string[] | object | The Array of tags to add to the check. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
Return:
* |
public childClient(options: object): * source
Creates a child client that adds prefix, suffix and/or tags to this client. Child client can itself have children.
Return:
* |
public decrement(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Decrements a stat by a specified amount
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public distribution(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Represents the distribution stat
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public event(title: string, text: string, options: object, tags: string[] | object, callback: function): * source
Send on an event
Params:
Name | Type | Attribute | Description |
title | string | The title of the event |
|
text | string | The description of the event. Optional- title is used if not given. |
|
options | object | Additional options |
|
options.date_happened | Date | Assign a timestamp to the event. Default is now. |
|
options.hostname | string | Assign a hostname to the event. |
|
options.aggregation_key | string | Assign an aggregation key to the event, to group it with some others. |
|
options.priority | string | Can be ‘normal’ or ‘low’. Default is 'normal'. |
|
options.source_type_name | string | Assign a source type to the event. |
|
options.alert_type | string | Can be ‘error’, ‘warning’, ‘info’ or ‘success’. Default is 'info'. |
|
tags | string[] | object | options.tags The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
Return:
* |
public gauge(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Gauges a stat by a specified amount
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public histogram(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Represents the histogram stat
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public increment(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Increments a stat by a specified amount
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public set(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Counts unique values by a specified amount
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public timer(func: function, stat: string | string[], sampleRate: number, tags: string[] | object, callback: function): * source
Represents the timing stat by recording the duration a function takes to run (in milliseconds)
Params:
Name | Type | Attribute | Description |
func | function | The function to run |
|
stat | string | string[] | The stat(s) to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
Return:
* |
public timing(stat: string | string[], time: number, sampleRate: number, tags: string[] | object, callback: function) source
Represents the timing stat
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
time | number | The time in milliseconds to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |
public unique(stat: string | string[], value: number, sampleRate: number, tags: string[] | object, callback: function) source
Counts unique values by a specified amount
Params:
Name | Type | Attribute | Description |
stat | string | string[] | The stat(s) to send |
|
value | number | The value to send |
|
sampleRate | number | The Number of times to sample (0 to 1). Optional. |
|
tags | string[] | object | The Array of tags to add to metrics. Optional. |
|
callback | function | Callback when message is done being delivered. Optional. |