v0.10.2
This release includes several new features and bugfixes!
New Features:
-
Support for distribution metrics. You can now send distributions to Datadog by doing:
const metrics = require('datadog-metrics'); metrics.distribution('my.metric.name', 3.8, ['tags:here']);
Distributions are similar to histograms (they create several metrics for count, average, percentiles, etc.), but they are calculated server-side on Datadog’s systems. For more details and guidance on when to use them, see:
- The documentation in this project’s README
- Datadog’s documentation at https://docs.datadoghq.com/metrics/distributions/
(Thanks to @Mr0grog.)
-
Add an
onError
option for handling asynchronous errors while flushing buffered metrics. You can use this to get details on an error or to send error info to a tracking service like Sentry.io:const metrics = require('datadog-metrics'); metrics.init({ onError (error) { console.error('There was an error sending to Datadog:', error); } });
-
The built-in reporter classes are now available for you to use. If you need to disable the metrics library for some reason, you can now do so with:
const metrics = require('datadog-metrics'); metrics.init({ reporter: new metrics.reporters.NullReporter(), });
(Thanks to @Mr0grog.)
-
Add an option for setting histogram defaults. In v0.10.0, the
histogram()
function gained the ability to set what aggregations and percentiles it generates with a finaloptions
argument. You can now specify ahistogram
option forinit()
orBufferedMetricsLogger
in order to set default options for all calls tohistogram()
. Any options you set in the actualhistogram()
call will layer on top of the defaults:const metrics = require('datadog-metrics'); metrics.init({ histogram: { aggregations: ['sum', 'avg'], percentiles: [0.99] } }); // Acts as if the options had been set to: // { aggregations: ['sum', 'avg'], percentiles: [0.99] } metrics.histogram('my.metric.name', 3.8); // Acts as if the options had been set to: // { aggregations: ['sum', 'avg'], percentiles: [0.5, 0.95] } metrics.histogram('my.metric.name', 3.8, [], Date.now(), { percentiles: [0.5, 0.95] });
(Thanks to @Mr0grog.)
-
Add a
.median
aggregation for histograms. When you log a histogram metric, it ultimately creates several metrics that track the minimum value, average value, maximum value, etc. There is now one that tracks the median value. StatsD creates the same metric from histograms, so you may find this useful if transitioning from StatsD. (Thanks to @Mr0grog.) -
This package no longer locks specific versions of its dependencies (instead, your package manager can choose any version that is compatible). This may help when deduplicating packages for faster installs or smaller bundles. (Thanks to @Mr0grog.)
Bug Fixes:
- Don’t use
unref()
on timers in non-Node.js environments. This is a step towards browser compatibility, although we are not testing browser-based usage yet. (Thanks to @Mr0grog.) - The
apiHost
option was broken in v0.10.0 and now works again. (Thanks to @Mr0grog and @npeters.) - Creating a second instance of
BufferedMetricsLogger
will no longer change the credentials used by previously createdBufferedMetricsLogger
instances. (Thanks to @Mr0grog.)
Internal Updates:
- Renamed the default branch in this repo to
main
. (Thanks to @dbader.) - Use GitHub actions for continuous integration. (Thanks to @Mr0grog.)
- Code style cleanup. (Thanks to @Mr0grog.)
- When flushing, send each metric with its own list of tags. This helps mitigate subtle errors where a change to one metric’s tags may affect others. (Thanks to @Mr0grog.)