@dazn/datadog-metrics
Advanced tools
Comparing version 1.4.0 to 1.5.0
let defaultTags = [], isInitialized = false, prefix | ||
let logger = console | ||
@@ -13,2 +14,6 @@ function init() { | ||
if (process.env.DISABLE_METRICS && process.env.DISABLE_METRICS.toLowerCase() === 'true') { | ||
logger = { log: () => null } | ||
} | ||
isInitialized = true | ||
@@ -22,3 +27,3 @@ } | ||
tags = defaultTags.concat(tags || []) | ||
console.log(`MONITORING|${timestamp}|${value}|gauge|${key}|#${tags.join(',')}`) | ||
logger.log(`MONITORING|${timestamp}|${value}|gauge|${key}|#${tags.join(',')}`) | ||
} | ||
@@ -33,3 +38,3 @@ | ||
tags = defaultTags.concat(tags || []) | ||
console.log(`MONITORING|${timestamp}|${value}|count|${key}|#${tags.join(',')}`) | ||
logger.log(`MONITORING|${timestamp}|${value}|count|${key}|#${tags.join(',')}`) | ||
} | ||
@@ -42,3 +47,3 @@ | ||
tags = defaultTags.concat(tags || []) | ||
console.log(`MONITORING|${timestamp}|${value}|histogram|${key}|#${tags.join(',')}`) | ||
logger.log(`MONITORING|${timestamp}|${value}|histogram|${key}|#${tags.join(',')}`) | ||
} | ||
@@ -51,3 +56,3 @@ | ||
tags = defaultTags.concat(tags || []) | ||
console.log(`MONITORING|${timestamp}|${value}|distribution|${key}|#${tags.join(',')}`) | ||
logger.log(`MONITORING|${timestamp}|${value}|distribution|${key}|#${tags.join(',')}`) | ||
} | ||
@@ -54,0 +59,0 @@ |
{ | ||
"name": "@dazn/datadog-metrics", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Records metrics with Datadog, supports both synchronous (via HTTP) and asynchronous (via Datadog's Lambda integration) modes. Defaults to asynchronous mode.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -78,1 +78,12 @@ # DAZN Datadog Metrics | ||
``` | ||
## Disabling console output | ||
Sometimes you won't want the console output to be displayed (e.g. when running your unit tests) when running in async mode. In order to do this, you can set the environment variable `DISABLE_METRICS=true`; this will disable console logging output. Note: Only set this for scenarios you don't want metrics to be recorded, as setting this will stop any metrics from being recorded. | ||
For example, your scripts section in `package.json` may look like this: | ||
```json | ||
"scripts": { | ||
"unit:test": "DISABLE_METRICS=true jest", | ||
... | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10483
170
88