seek-datadog-custom-metrics
Advanced tools
Comparing version 3.0.1 to 4.0.0
@@ -13,11 +13,8 @@ "use strict"; | ||
* | ||
* @param StatsD - StatsD class from `hot-shots` | ||
* @param config - Application configuration | ||
* @param errorHandler - Optional error handler function | ||
*/ | ||
exports.default = (config, errorHandler) => { | ||
// Avoid a hard dependency on `hot-shots` for e.g. Lambda CloudWatch users | ||
// This severely angers TypeScript in multiple ways. | ||
// eslint-disable-next-line | ||
const StatsDClass = require('hot-shots').StatsD; | ||
const client = new StatsDClass({ | ||
exports.default = (StatsD, config, errorHandler) => { | ||
const client = new StatsD({ | ||
// Disable ourselves if there's no configured metrics server | ||
@@ -24,0 +21,0 @@ mock: !config.metricsServer, |
@@ -8,11 +8,8 @@ import globalTags from './globalTags'; | ||
* | ||
* @param StatsD - StatsD class from `hot-shots` | ||
* @param config - Application configuration | ||
* @param errorHandler - Optional error handler function | ||
*/ | ||
export default (config, errorHandler) => { | ||
// Avoid a hard dependency on `hot-shots` for e.g. Lambda CloudWatch users | ||
// This severely angers TypeScript in multiple ways. | ||
// eslint-disable-next-line | ||
const StatsDClass = require('hot-shots').StatsD; | ||
const client = new StatsDClass({ | ||
export default (StatsD, config, errorHandler) => { | ||
const client = new StatsD({ | ||
// Disable ourselves if there's no configured metrics server | ||
@@ -19,0 +16,0 @@ mock: !config.metricsServer, |
import AppConfig from './AppConfig'; | ||
import MetricsClient from './MetricsClient'; | ||
interface InternalStatsD extends MetricsClient { | ||
socket?: { | ||
close(callback?: () => void): void; | ||
}; | ||
} | ||
interface StatsD<T extends InternalStatsD> { | ||
new (options?: { | ||
mock?: boolean; | ||
host?: string; | ||
errorHandler?: (err: Error) => void; | ||
prefix?: string; | ||
globalTags?: Record<string, string> | string[]; | ||
}): T; | ||
} | ||
/** | ||
@@ -15,3 +29,3 @@ * Configuration for building a StatsD client | ||
} | ||
declare const _default: (config: StatsDConfig, errorHandler?: ((err: Error) => void) | undefined) => MetricsClient; | ||
declare const _default: <T extends InternalStatsD>(StatsD: StatsD<T>, config: StatsDConfig, errorHandler?: ((err: Error) => void) | undefined) => T; | ||
/** | ||
@@ -23,2 +37,3 @@ * Creates a new StatsD client configured for the given app | ||
* | ||
* @param StatsD - StatsD class from `hot-shots` | ||
* @param config - Application configuration | ||
@@ -25,0 +40,0 @@ * @param errorHandler - Optional error handler function |
@@ -8,5 +8,5 @@ { | ||
"devDependencies": { | ||
"@types/node": "14.11.2", | ||
"hot-shots": "7.8.0", | ||
"skuba": "3.9.2" | ||
"@types/node": "14.14.7", | ||
"hot-shots": "8.2.0", | ||
"skuba": "3.10.1" | ||
}, | ||
@@ -51,3 +51,3 @@ "files": [ | ||
"types": "./lib-types/index.d.ts", | ||
"version": "3.0.1" | ||
"version": "4.0.0" | ||
} |
@@ -46,2 +46,3 @@ # 🐶 Datadog Custom Metrics | ||
```typescript | ||
import { StatsD } from 'hot-shots'; | ||
import { createStatsDClient } from 'seek-datadog-custom-metrics'; | ||
@@ -59,3 +60,3 @@ | ||
// Returns a standard hot-shots StatsD instance | ||
const metricsClient = createStatsDClient(config, errorHandler); | ||
const metricsClient = createStatsDClient(StatsD, config, errorHandler); | ||
``` | ||
@@ -62,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
33330
466
108