forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statsd-client.d.ts
104 lines (83 loc) · 2.37 KB
/
statsd-client.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Type definitions for statsd-client v0.1.0
// Project: https://github.com/msiebuhr/node-statsd-client
// Definitions by: Peter Kooijmans <https://github.com/peterkooijmans/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "statsd-client" {
interface CommonOptions {
/**
* Prefix all stats with this value (default "").
*/
prefix?: string;
/**
* Print what is being sent to stderr (default false).
*/
debug?: boolean;
/**
* User specifically wants to use tcp (default false)
*/
tcp?: boolean;
/**
* Dual-use timer. Will flush metrics every interval. For UDP,
* it auto-closes the socket after this long without activity
* (default 1000 ms; 0 disables this). For TCP, it auto-closes
* the socket after socketTimeoutsToClose number of timeouts
* have elapsed without activity.
*/
socketTimeout?: number;
}
interface TcpOptions extends CommonOptions {
/**
* Where to send the stats (default localhost).
*/
host?: string;
/**
* Port to contact the statsd-daemon on (default 8125).
*/
port?: number;
/**
* Number of timeouts in which the socket auto-closes if it
* has been inactive. (default 10; 1 to auto-close after a
* single timeout).
*/
socketTimeoutsToClose: number;
}
interface UdpOptions extends CommonOptions {
/**
* Where to send the stats (default localhost).
*/
host?: string;
/**
* Port to contact the statsd-daemon on (default 8125).
*/
port?: number;
}
interface HttpOptions extends CommonOptions {
/**
* Where to send the stats (default localhost).
*/
host?: string;
/**
* Additional headers to send (default {}).
*/
headers?: { [index : string] : string };
/**
* What HTTP method to use (default "PUT").
*/
method?: string;
}
class StatsdClient {
constructor(options: TcpOptions | UdpOptions | HttpOptions);
counter(metric: string, delta: number): void;
increment(metric: string, delta?: number): void;
decrement(metric: string, delta?: number): void;
gauge(name: string, value: number): void;
gaugeDelta(name: string, delta: number): void;
set(name: string, value: number): void;
timing(name: string, start: Date): void;
timing(name: string, duration: number): void;
close(): void;
getChildClient(name: string): StatsdClient;
}
namespace StatsdClient {}
export = StatsdClient;
}