Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/statsd

Package Overview
Dependencies
Maintainers
19
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/statsd - npm Package Compare versions

Comparing version 4.0.1 to 4.1.0

37

build/cjs/client.js

@@ -10,6 +10,3 @@ 'use strict';

class StatsDClient {
constructor({
logger,
...options
}) {
constructor(options) {
this.statsd = void 0;

@@ -19,2 +16,21 @@ this.logger = console;

if (isChildOptions(options)) {
const {
client,
...childOptions
} = options;
this.logger = client.logger;
this.options = { ...client.options,
...childOptions
};
this.statsd = client.statsd.childClient(childOptions);
return;
}
const {
logger,
snakeCase,
...statsdOptions
} = options;
if (logger) {

@@ -25,3 +41,3 @@ this.logger = logger;

this.options = { ...options,
errorHandler: options.errorHandler ? options.errorHandler : error => {
errorHandler: statsdOptions.errorHandler ? statsdOptions.errorHandler : error => {
this.logger.log(`Error occurred in the StatsD client:\n${error.stack || error.message}`);

@@ -63,2 +79,9 @@ }

childClient(options) {
return new StatsDClient({
client: this,
...options
});
}
addGlobalTags(globalTags) {

@@ -102,2 +125,6 @@ this.statsd = this.statsd.childClient({

function isChildOptions(options) {
return 'client' in options;
}
exports.StatsDClient = StatsDClient;

18

build/ts/client.d.ts

@@ -1,2 +0,2 @@

import { ClientOptions } from 'hot-shots';
import { StatsD, ClientOptions as HotShotClientOptions, ChildClientOptions as HotShotChildOptions } from 'hot-shots';
export interface Logger {

@@ -8,11 +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 HotShotChildOptions {
client: StatsDClient;
snakeCase?: boolean;
}
export declare type Options = ClientOptions | ChildOptions;
export declare class StatsDClient {
private statsd;
private logger;
private options;
constructor({ logger, ...options }: Options);
protected statsd: StatsD;
protected logger: Logger;
protected options: ClientOptions;
constructor(options: Options);
distribution(stat: string | string[], value: number, tags?: Tags): Promise<void>;

@@ -23,2 +28,3 @@ timing(stat: string | string[], value: number, tags?: Tags): Promise<void>;

close(): Promise<void>;
childClient(options?: Omit<ChildOptions, 'client'>): StatsDClient;
addGlobalTags(globalTags: Tags): void;

@@ -25,0 +31,0 @@ private createCallback;

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": "4.0.1",
"version": "4.1.0",
"license": "MIT",

@@ -28,3 +28,3 @@ "description": "An opinionated StatsD client for Shopify Node.js servers and other StatsD utilities",

"change-case": "^4.1.1",
"hot-shots": "^8.2.0"
"hot-shots": "^9.3.0"
},

@@ -31,0 +31,0 @@ "files": [

@@ -12,3 +12,3 @@ # `@shopify/statsd`

```bash
$ yarn add @shopify/statsd
yarn add @shopify/statsd
```

@@ -29,2 +29,3 @@

prefix: 'AppName',
globalTags: {hello: 'world'},
});

@@ -45,2 +46,26 @@ ```

#### `timing`
Represents the timing stat
```javascript
statsdClient.timing(
'request_duration',
100, // in milliseconds
[], // user-defined tags to go with the data
);
```
#### `gauge`
Represents the gauge stat
```javascript
statsdClient.gauge(
'my_gauge',
123.45, // value
[], // user-defined tags to go with the data
);
```
#### `increment`

@@ -65,1 +90,17 @@

```
#### `childClient`
Create a child client and add more context to the client.
The globalTags will be merged.
The prefix and suffix will be concatenate using the `.` separator.
```javascript
statsdClient.childClient({
prefix: 'MyPrefix',
suffix: 'MySuffix',
globalTags: {foo: 'bar'},
});
```
In this example the prefix will be `AppName.NewPrefix`, the suffix will be `MySuffix` 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc