datadog-metrics\nFix how per-metric tags are passed in. Support new timestamp param.

This commit is contained in:
jeff
2017-11-08 08:38:53 -08:00
parent e5620215b5
commit 0d198a5ce3
2 changed files with 14 additions and 8 deletions
@@ -1,9 +1,12 @@
import metrics = require('datadog-metrics');
metrics.init({ host: 'myhost', prefix: 'myapp.' });
metrics.gauge('mygauge', 42);
metrics.gauge("mykey", 11, ["a", "b", "c"], Date.now());
metrics.increment('test.requests_served');
metrics.increment('test.awesomeness_factor', 10);
metrics.histogram('test.service_time', 0.248);
metrics.increment('test.service_time', 0.248);
metrics.histogram("mykey", 11, ["a", "b", "c"], Date.now());
metrics.histogram("mykey", 11, ["a", "b", "c"], Date.now());
metrics.flush();
metrics.flush(() => {});
metrics.flush(() => {}, err => {});
@@ -16,9 +19,12 @@ const metricsLogger = new metrics.BufferedMetricsLogger({
defaultTags: ['env:staging', 'region:us-east-1']
});
metricsLogger.gauge('mygauge', 42);
metricsLogger.gauge("mykey", 11, ["a", "b", "c"], Date.now());
metricsLogger.increment('test.requests_served');
metricsLogger.increment('test.awesomeness_factor', 10);
metricsLogger.increment("mykey", 11, ["a", "b", "c"], Date.now());
metricsLogger.histogram('test.service_time', 0.248);
metricsLogger.histogram("mykey", 11, ["a", "b", "c"], Date.now());
metricsLogger.flush();
metricsLogger.flush(() => {});
metricsLogger.flush(() => {}, err => {});
+7 -7
View File
@@ -1,4 +1,4 @@
// Type definitions for datadog-metrics 0.4
// Type definitions for datadog-metrics 0.6
// Project: https://github.com/dbader/node-datadog-metrics
// Definitions by: Jeffery Grajkowski <https://github.com/pushplay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -44,21 +44,21 @@ export class BufferedMetricsLogger {
* the metric. This should be used for sum values such as total hard disk space,
* process uptime, total number of active users, or number of rows in a database table.
*/
gauge(key: string, value: number, ...tags: string[]): void;
gauge(key: string, value: number, tags?: string[], timestamp?: number): void;
/**
* Increment the counter by the given value (or 1 by default). Optionally, specify a
* list of tags to associate with the metric. This is useful for counting things such
* as incrementing a counter each time a page is requested.
*/
increment(key: string, value?: number, ...tags: string[]): void;
increment(key: string, value?: number, tags?: string[], timestamp?: number): void;
/**
* Sample a histogram value. Histograms will produce metrics that describe the distribution
* of the recorded values, namely the minimum, maximum, average, count and the 75th, 85th,
* 95th and 99th percentiles. Optionally, specify a list of tags to associate with the metric.
*/
histogram(key: string, value: number, ...tags: string[]): void;
histogram(key: string, value: number, tags?: string[], timestamp?: number): void;
/**
* Calling flush sends any buffered metrics to DataDog. Unless you set flushIntervalSeconds
@@ -77,21 +77,21 @@ export function init(options: BufferedMetricsLoggerOptions): void;
* the metric. This should be used for sum values such as total hard disk space,
* process uptime, total number of active users, or number of rows in a database table.
*/
export function gauge(key: string, value: number, ...tags: string[]): void;
export function gauge(key: string, value: number, tags?: string[], timestamp?: number): void;
/**
* Increment the counter by the given value (or 1 by default). Optionally, specify a
* list of tags to associate with the metric. This is useful for counting things such
* as incrementing a counter each time a page is requested.
*/
export function increment(key: string, value?: number, ...tags: string[]): void;
export function increment(key: string, value?: number, tags?: string[], timestamp?: number): void;
/**
* Sample a histogram value. Histograms will produce metrics that describe the distribution
* of the recorded values, namely the minimum, maximum, average, count and the 75th, 85th,
* 95th and 99th percentiles. Optionally, specify a list of tags to associate with the metric.
*/
export function histogram(key: string, value: number, ...tags: string[]): void;
export function histogram(key: string, value: number, tags?: string[], timestamp?: number): void;
/**
* Calling flush sends any buffered metrics to DataDog. Unless you set flushIntervalSeconds