Buffered metrics reporting via the DataDog HTTP API
MIT License
Fixes & Maintenance:
Fix types and documentation for the aggregates
option for histograms and the histogram.aggregates
option for the library as a whole. It was previously listed as aggregations
, which was incorrect. (Thanks to @Calyhre in #117.)
Improve documentation and add a more detailed error message about API keys vs. application keys. (#118)
Published by Mr0grog about 1 year ago
Fixes & Maintenance:
Published by Mr0grog over 1 year ago
New Features:
Built-in TypeScript definitions. If you use TypeScript, you no longer need to install separate type definitions from @types/datadog-metrics
— they’re now built-in. Please make sure to remove @types/datadog-metrics
from your dev dependencies.
Even if you’re writing regular JavaScript, you should now see better autocomplete suggestions and documentation in editors that support TypeScript definitions (e.g. VisualStudio Code, WebStorm).
Breaking Changes:
class
syntax internally. In most cases, you shouldn’t need to change anything. However, if you are calling BufferedMetricsLogger.apply(...)
or BufferedMetricsLogger.call(...)
, you’ll need to change your code to use new BufferedMetricsLogger(...)
instead.Deprecated Features:
The apiHost
option has been renamed to site
so that it matches up with Datadog docs and official packages. The old apiHost
name still works for now, but will be removed in the future.
The reporters.DataDogReporter
class has been renamed to reporters.DatadogReporter
(lower-case D in "dog") so that it correctly matches Datadog’s actual name. The old name still works, but will be removed in the future.
Published by Mr0grog about 2 years ago
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:
(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 final options
argument. You can now specify a histogram
option for init()
or BufferedMetricsLogger
in order to set default options for all calls to histogram()
. Any options you set in the actual histogram()
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:
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.)apiHost
option was broken in v0.10.0 and now works again. (Thanks to @Mr0grog and @npeters.)BufferedMetricsLogger
will no longer change the credentials used by previously created BufferedMetricsLogger
instances. (Thanks to @Mr0grog.)Internal Updates:
main
. (Thanks to @dbader.)Published by Mr0grog about 2 years ago
@datadog/datadog-api-client
was not used correctly. (Thanks to @gquinteros93)Published by Mr0grog about 2 years ago
Breaking change: we now use Datadog’s official @datadog/datadog-api-client
package to send metrics to Datadog. This makes datadog-metrics
usable with Webpack, but removes the agent
option. If you were using this option and the new library does not provide a way to meet your needs, please let us know by filing an issue! (Thanks to @thatguychrisw)
You can now customize what metrics are generated by a histogram. When logging a histogram metric, the 5th argument is an optional object with information about which aggregations and percentiles to create metrics for:
const metrics = require('datadog-metrics');
metrics.histogram('my.metric.name', 3.8, [], Date.now(), {
// Aggregates can include 'max', 'min', 'sum', 'avg', or 'count'.
aggregations: ['max', 'min', 'sum', 'avg', 'count'],
// Percentiles can include any decimal between 0 and 1.
percentiles: [0.75, 0.85, 0.95, 0.99]
});
(Thanks to @gquinteros93.)
INTERNAL: Clean up continuous integration on TravisCI. (Thanks to @ErikBoesen.)