node-datadog-metrics
node-datadog-metrics copied to clipboard
Add support for distribution metrics
This adds support for DataDog’s distribution
metric type, which is sort of like a histogram except is sends every point to DataDog and does the statistics in their system, rather than in the client here. (This also can work as a solution to #53 — distribution points with the same metric name and tags won’t get overwritten on DataDog’s end; that’s actually part of the whole point of distributions as I understand it, since this is the only real feasible approach for things like AWS Lambda.)
You can call it just like you would a histogram:
const metrics = require("datadog-metrics");
metrics.distribution("my.metric.name", 5.3, ["a:few", "tags:here"]);
I tested this a few times with a live DataDog account, and it seems to work well. The way I’ve collapsed metrics from the same second gets the right results in graphs, as do out of order (time-wise) points, so we don’t need to worry about sorting.
This involves a somewhat complex change to the reporter, where it has to split the list of metrics in two (one for distributions and one for normal metrics) because distributions get sent to a different API endpoint. That seemed like the best place to do it, otherwise a lot of other stuff throughout the library would need to change in order to accommodate multiple lists of different kinds of metrics.
Fixes #46.