Skip to main content
Module

x/statsd/mod.ts>StatsDClient

A simple StatsD client for Deno
Latest
class StatsDClient
import { StatsDClient } from "https://deno.land/x/statsd@0.5.0/mod.ts";

StatsD client. Use this to send data to a StatsD-speaking backend.

Constructors

new
StatsDClient(conf?: LibConfig)

Build a new client. This client will have its own connection to the remote StatsD server.

If no config object is passed in, we'll 100% fall back on default settings. (localhost:8125, UDP, ...)

Methods

private
getClient(): Client
private
getHostname(): string
adjustGauge(
key: string,
delta: number,
opts?: MetricOpts,
)

Sends a relative "gauge" metric. A relative gauge metric may reference a gauge value (an absolute measurement) but we aren't sending that exact measurement right now. We're just sending an adjustment value.

close(): Promise<void>

Will flush all pending metrics, and close all open sockets.

Any attempts to use this client after close() should error.

count(
key: string,
num?,
opts?: MetricOpts,
)

Send a "count" metric. This is used to track the number of things.

deprecated
distribution(
key: string,
value: number,
opts?: MetricOpts,
)

Sends a "distribution" metric. A distribution seems to be functionally equivalent to a timing metric, but has its own page in datadog that has been deprecated.

This extension to the StatsD protocol is only available when the Dialect is "datadog". Normal StatsD setups should just use the timer metric.

Sends an "event" to datadog.

This method will only work if the dialect is "datadog".

gauge(
key: string,
value: number,
opts?: MetricOpts,
)

Sends a "gauge" metric. Gauges are point-in-time measurements, that are true, at this time. The StatsD server will keep gauges in memory, and will keep using them if a new value wasn't sent. Use this to track values that are absolutely true, at this point-in-time. This could include things like "number of items in a db table", or "bytes remaining in the main disk partition." Things like that.

deprecated
histogram(
key: string,
value: number,
opts?: MetricOpts,
)

Sends a "histogram" metric. A histogram is pretty much the same thing as a timer, but created by datadog, and not compatible with StatsD.

I don't get it either.

This extension to the StatsD protocol is only available when the Dialect is "datadog". Normal StatsD setups should just use the timer metric.

Sends a "service check" to datadog.

This method will only work if the dialect is "datadog".

timing(
key: string,
ms: number,
opts?: MetricOpts,
)

Sends a "timing" metric, typically measured in milliseconds. The remote StatsD server will usually calculate other metrics based on these values. These metrics can include things like: min, max, average, mean90, etc...

While this metric type was originally intended only for timing measurements, it can really be used for any value where things like min, max, mean90, etc... would be useful.

unique(
key: string,
value: number | string,
opts?: MetricOpts,
)

Sends a "set" metric. A set metric tracks the number of distinct values seen in StatsD over time. Use this to track things like the number of disctint users.