mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Add node-dogstatsd definitions and tests (#10795)
* Add node-dogstatsd definitions and tests * Correct project url
This commit is contained in:
committed by
Masahiro Wakame
parent
8fb286186b
commit
f103abe02a
48
node-dogstatsd/node-dogstatsd-tests.ts
Normal file
48
node-dogstatsd/node-dogstatsd-tests.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/// <reference path="./node-dogstatsd.d.ts" />
|
||||
|
||||
import * as datadog from 'node-dogstatsd';
|
||||
|
||||
function test_statsd_client() {
|
||||
// can create client with defaults
|
||||
let client = new datadog.StatsD('localhost');
|
||||
let options: datadog.StatsDOptions = { global_tags: ['environment:definitely_typed']};
|
||||
|
||||
// can create client with all params
|
||||
client = new datadog.StatsD('localhost', 8125, null, options);
|
||||
|
||||
let key: string = 'key';
|
||||
let timeValue: number = 99;
|
||||
let sampleRate: number = 0.85;
|
||||
let incrementBy: number = 7;
|
||||
let decrementBy: number = 5;
|
||||
let gaugeValue: number = 199;
|
||||
let tags: string[] = ['tag1', 'tag2'];
|
||||
|
||||
client.timing(key, timeValue);
|
||||
client.timing(key, timeValue, sampleRate);
|
||||
client.timing(key, timeValue, sampleRate, tags);
|
||||
|
||||
client.increment(key);
|
||||
client.increment(key, sampleRate);
|
||||
client.increment(key, sampleRate, tags);
|
||||
|
||||
client.incrementBy(key, incrementBy);
|
||||
client.incrementBy(key, incrementBy, tags);
|
||||
|
||||
client.decrement(key);
|
||||
client.decrement(key, sampleRate);
|
||||
client.decrement(key, sampleRate, tags);
|
||||
|
||||
client.decrementBy(key, decrementBy);
|
||||
client.decrementBy(key, decrementBy, tags);
|
||||
|
||||
client.gauge(key, gaugeValue);
|
||||
client.gauge(key, gaugeValue, sampleRate);
|
||||
client.gauge(key, gaugeValue, sampleRate, tags);
|
||||
|
||||
client.histogram(key, timeValue);
|
||||
client.histogram(key, timeValue, sampleRate);
|
||||
client.histogram(key, timeValue, sampleRate, tags);
|
||||
|
||||
client.close();
|
||||
}
|
||||
29
node-dogstatsd/node-dogstatsd.d.ts
vendored
Normal file
29
node-dogstatsd/node-dogstatsd.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Type definitions for Datadog's nodejs metrics client node-dogstatsd
|
||||
// Project: https://github.com/joybro/node-dogstatsd
|
||||
// Definitions by: Chris Bobo <https://github.com/chrisbobo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "node-dogstatsd" {
|
||||
|
||||
export interface StatsDOptions {
|
||||
global_tags?: string[];
|
||||
}
|
||||
|
||||
export class StatsD {
|
||||
constructor(host: string, port?: number, socket?: string, options?: StatsDOptions);
|
||||
|
||||
timing(stat: string, time: number, sample_rate?: number, tags?: string[]): void;
|
||||
|
||||
increment(stat: string, sample_rate?: number, tags?: string[]): void;
|
||||
incrementBy(stat: string, value: number, tags?: string[]): void;
|
||||
|
||||
decrement(stat: string, sample_rate?: number, tags?: string[]): void;
|
||||
decrementBy(stat: string, value: number, tags?: string[]): void;
|
||||
|
||||
gauge(stat: string, value: number, sample_rate?: number, tags?: string[]): void;
|
||||
|
||||
histogram(stat: string, time: number, sample_rate?: number, tags?: string[]): void;
|
||||
|
||||
close(): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user