Merge branch 'fix/concat-tags'

This commit is contained in:
Tom Moor
2021-06-16 18:36:28 -07:00

View File

@ -9,11 +9,7 @@ if (process.env.DD_API_KEY) {
}); });
} }
export function gauge( export function gauge(key: string, value: number, tags?: string[]): void {
key: string,
value: number,
tags?: { [string]: string }
): void {
if (!process.env.DD_API_KEY) { if (!process.env.DD_API_KEY) {
return; return;
} }
@ -24,16 +20,20 @@ export function gauge(
export function gaugePerInstance( export function gaugePerInstance(
key: string, key: string,
value: number, value: number,
tags?: { [string]: string } = {} tags?: string[] = []
): void { ): void {
if (!process.env.DD_API_KEY) { if (!process.env.DD_API_KEY) {
return; return;
} }
return metrics.gauge(key, value, { const instanceId = process.env.INSTANCE_ID || process.env.HEROKU_DYNO_ID;
...tags, if (!instanceId) {
instance: process.env.INSTANCE_ID || process.env.HEROKU_DYNO_ID, throw new Error(
}); "INSTANCE_ID or HEROKU_DYNO_ID must be set when using Datadog"
);
}
return metrics.gauge(key, value, [...tags, `instance:${instanceId}`]);
} }
export function increment(key: string, tags?: { [string]: string }): void { export function increment(key: string, tags?: { [string]: string }): void {