-
Notifications
You must be signed in to change notification settings - Fork 135
/
types.d.ts
159 lines (134 loc) · 8.08 KB
/
types.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import dgram = require("dgram");
import stream = require("stream");
declare module "hot-shots" {
export type Tags = { [key: string]: string } | string[];
export interface ClientOptions {
bufferFlushInterval?: number;
bufferHolder?: { buffer: string };
cacheDns?: boolean;
cacheDnsTtl?: number;
errorHandler?: (err: Error) => void;
globalTags?: Tags;
includeDataDogTags?: boolean;
globalize?: boolean;
host?: string;
isChild?: boolean;
maxBufferSize?: number;
mock?: boolean;
path?: string;
port?: number;
prefix?: string;
protocol?: 'tcp' | 'udp' | 'uds' | 'stream';
sampleRate?: number;
socket?: dgram.Socket;
stream?: stream.Writable;
suffix?: string;
telegraf?: boolean;
useDefaultRoute?: boolean;
tagPrefix?: string;
tagSeparator?: string;
tcpGracefulErrorHandling?: boolean;
tcpGracefulRestartRateLimit?: number;
udsGracefulErrorHandling?: boolean;
udsGracefulRestartRateLimit?: number;
closingFlushInterval?: number;
udpSocketOptions?: dgram.SocketOptions;
}
export interface ChildClientOptions {
globalTags?: Tags;
prefix?: string;
suffix?: string;
}
export interface CheckOptions {
date_happened?: Date;
hostname?: string;
message?: string;
}
export interface DatadogChecks {
OK: 0;
WARNING: 1;
CRITICAL: 2;
UNKNOWN: 3;
}
type unionFromInterfaceValues4<
T,
K1 extends keyof T,
K2 extends keyof T,
K3 extends keyof T,
K4 extends keyof T,
> = T[K1] | T[K2] | T[K3] | T[K4];
export type DatadogChecksValues = unionFromInterfaceValues4<DatadogChecks, "OK", "WARNING", "CRITICAL", "UNKNOWN">;
export interface EventOptions {
aggregation_key?: string;
alert_type?: "info" | "warning" | "success" | "error";
date_happened?: Date;
hostname?: string;
priority?: "low" | "normal";
source_type_name?: string;
}
export type StatsCb = (error?: Error, bytes?: number) => void;
export class StatsD {
constructor(options?: ClientOptions);
childClient(options?: ChildClientOptions): StatsD;
increment(stat: string, tags?: Tags): void;
increment(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
increment(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
increment(stat: string | string[], value: number, callback?: StatsCb): void;
increment(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
decrement(stat: string): void;
decrement(stat: string, tags?: Tags): void;
decrement(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
decrement(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
decrement(stat: string | string[], value: number, callback?: StatsCb): void;
decrement(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
timing(stat: string | string[], value: number | Date, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
timing(stat: string | string[], value: number | Date, tags?: Tags, callback?: StatsCb): void;
timing(stat: string | string[], value: number | Date, callback?: StatsCb): void;
timing(stat: string | string[], value: number | Date, sampleRate?: number, callback?: StatsCb): void;
timer<P extends any[], R>(func: (...args: P) => R, stat: string | string[], sampleRate?: number, tags?: Tags, callback?: StatsCb): (...args: P) => R;
timer<P extends any[], R>(func: (...args: P) => R, stat: string | string[], tags?: Tags, callback?: StatsCb): (...args: P) => R;
timer<P extends any[], R>(func: (...args: P) => R, stat: string | string[], callback?: StatsCb): (...args: P) => R;
timer<P extends any[], R>(func: (...args: P) => R, stat: string | string[], sampleRate?: number, callback?: StatsCb): (...args: P) => R;
asyncTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], sampleRate?: number, tags?: Tags, callback?: StatsCb): (...args: P) => Promise<R>;
asyncTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], tags?: Tags, callback?: StatsCb): (...args: P) => Promise<R>;
asyncTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], callback?: StatsCb): (...args: P) => Promise<R>;
asyncTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], sampleRate?: number, callback?: StatsCb): (...args: P) => Promise<R>;
asyncDistTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], sampleRate?: number, tags?: Tags, callback?: StatsCb): (...args: P) => Promise<R>;
asyncDistTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], tags?: Tags, callback?: StatsCb): (...args: P) => Promise<R>;
asyncDistTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], callback?: StatsCb): (...args: P) => Promise<R>;
asyncDistTimer<P extends any[], R>(func: (...args: P) => Promise<R>, stat: string | string[], sampleRate?: number, callback?: StatsCb): (...args: P) => Promise<R>;
histogram(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
histogram(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
histogram(stat: string | string[], value: number, callback?: StatsCb): void;
histogram(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
distribution(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
distribution(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
distribution(stat: string | string[], value: number, callback?: StatsCb): void;
distribution(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
gauge(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
gauge(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
gauge(stat: string | string[], value: number, callback?: StatsCb): void;
gauge(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
gaugeDelta(stat: string | string[], value: number, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
gaugeDelta(stat: string | string[], value: number, tags?: Tags, callback?: StatsCb): void;
gaugeDelta(stat: string | string[], value: number, callback?: StatsCb): void;
gaugeDelta(stat: string | string[], value: number, sampleRate?: number, callback?: StatsCb): void;
set(stat: string | string[], value: number | string, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
set(stat: string | string[], value: number | string, tags?: Tags, callback?: StatsCb): void;
set(stat: string | string[], value: number | string, callback?: StatsCb): void;
set(stat: string | string[], value: number | string, sampleRate?: number, callback?: StatsCb): void;
unique(stat: string | string[], value: number | string, sampleRate?: number, tags?: Tags, callback?: StatsCb): void;
unique(stat: string | string[], value: number | string, tags?: Tags, callback?: StatsCb): void;
unique(stat: string | string[], value: number | string, callback?: StatsCb): void;
unique(stat: string | string[], value: number | string, sampleRate?: number, callback?: StatsCb): void;
close(callback?: (error?: Error) => void): void;
event(title: string, text?: string, options?: EventOptions, tags?: Tags, callback?: StatsCb): void;
event(title: string, text?: string, options?: EventOptions, callback?: StatsCb): void;
check(name: string, status: DatadogChecksValues, options?: CheckOptions, tags?: Tags, callback?: StatsCb): void;
public CHECKS: DatadogChecks;
public mockBuffer?: string[];
public socket: dgram.Socket;
}
}
declare const StatsDClient: new (options?: ClientOptions) => StatsD;
export default StatsDClient;