@shopify/statsd
Advanced tools
Comparing version 0.0.0-snapshot-20221206153119 to 0.0.0-snapshot-20221206230340
@@ -18,2 +18,3 @@ 'use strict'; | ||
client, | ||
prefix, | ||
...childOptions | ||
@@ -26,2 +27,12 @@ } = options; | ||
this.statsd = client.statsd.childClient(childOptions); | ||
if (prefix) { | ||
// The concatenation of the prefix in the library is the inverse of what we want. | ||
// The library concatenates the prefix like that: <ChildPrefix><ParentPrefix> | ||
// but in most case we want to concatenate like this: <ParentPrefix><ChildPrefix> | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.statsd.prefix = `${this.statsd.prefix}${prefix}`; | ||
} | ||
return; | ||
@@ -28,0 +39,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { StatsD, ClientOptions, ChildClientOptions } from 'hot-shots'; | ||
import { StatsD, ClientOptions as HotShotClientOptions, ChildClientOptions as HotShotChildOptions } from 'hot-shots'; | ||
export interface Logger { | ||
@@ -8,15 +8,16 @@ log(message: string): void; | ||
} | string[]; | ||
export interface Options extends ClientOptions { | ||
export interface ClientOptions extends HotShotClientOptions { | ||
logger?: Logger; | ||
snakeCase?: boolean; | ||
} | ||
export interface ChildOptions extends ChildClientOptions { | ||
export interface ChildOptions extends HotShotChildOptions { | ||
client: StatsDClient; | ||
snakeCase?: boolean; | ||
} | ||
export declare type Options = ClientOptions | ChildOptions; | ||
export declare class StatsDClient { | ||
protected statsd: StatsD; | ||
protected logger: Logger; | ||
protected options: Options; | ||
constructor(options: Options | ChildOptions); | ||
protected options: ClientOptions; | ||
constructor(options: Options); | ||
distribution(stat: string | string[], value: number, tags?: Tags): Promise<void>; | ||
@@ -23,0 +24,0 @@ timing(stat: string | string[], value: number, tags?: Tags): Promise<void>; |
export { StatsDClient } from './client'; | ||
export type { Logger, Options } from './client'; | ||
export type { Logger, Options, ClientOptions, ChildOptions } from './client'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@shopify/statsd", | ||
"version": "0.0.0-snapshot-20221206153119", | ||
"version": "0.0.0-snapshot-20221206230340", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "An opinionated StatsD client for Shopify Node.js servers and other StatsD utilities", |
@@ -28,2 +28,3 @@ # `@shopify/statsd` | ||
prefix: 'AppName', | ||
suffix: 'AppSuffix', | ||
globalTags: {hello: 'world'}, | ||
@@ -93,8 +94,8 @@ }); | ||
The globalTags will be merged. | ||
The prefix and suffix will be concatenate using the `.` separator. | ||
The prefix and suffix will be concatenated like in this example. | ||
```javascript | ||
statsdClient.childClient({ | ||
prefix: 'MyPrefix', | ||
suffix: 'MySuffix', | ||
prefix: '.NewPrefix', | ||
suffix: '.NewSuffix', | ||
globalTags: {foo: 'bar'}, | ||
@@ -104,2 +105,2 @@ }); | ||
In this example the prefix will be `AppName.NewPrefix`, the suffix will be `MySuffix` and the globalTags will be `{hello: 'world', foo: 'bar'}`. | ||
In this example the prefix will be `AppName.NewPrefix`, the suffix will be `AppSuffix.NewSuffix` and the globalTags will be `{hello: 'world', foo: 'bar'}`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
16494
257
104