@oino-ts/types 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
export declare abstract class OINOBenchmark {
|
|
6
6
|
protected static _instance: OINOBenchmark;
|
|
7
7
|
protected static _enabled: Record<string, boolean>;
|
|
8
|
+
protected static _healthBenchmarks: string[];
|
|
9
|
+
protected static _healthLateRatio: number;
|
|
8
10
|
/**
|
|
9
11
|
* Create a new OINOBenchmark instance.
|
|
10
12
|
*
|
|
@@ -23,6 +25,30 @@ export declare abstract class OINOBenchmark {
|
|
|
23
25
|
*
|
|
24
26
|
*/
|
|
25
27
|
static getInstance(): OINOBenchmark;
|
|
28
|
+
/**
|
|
29
|
+
* Add benchmark to be used for service health monitoring.
|
|
30
|
+
* @param module of the benchmark
|
|
31
|
+
* @param method of the benchmark
|
|
32
|
+
*/
|
|
33
|
+
static addHealthBenchmark(module: string, method: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Remove benchmark from being used for service health monitoring.
|
|
36
|
+
* @param module of the benchmark
|
|
37
|
+
* @param method of the benchmark
|
|
38
|
+
*/
|
|
39
|
+
static removeHealthBenchmark(module: string, method: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Set late ratio threshold for health monitoring. If a request takes this many times longer than the average duration, it is considered late and a health failure.
|
|
42
|
+
* @param lateRatio of health benchmarks, e.g. 2.0 means requests that take 2 times longer than the average
|
|
43
|
+
*/
|
|
44
|
+
static setHealthLateRatio(lateRatio: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get service health based on the configured health benchmark.
|
|
47
|
+
*
|
|
48
|
+
* @returns service health as 0-1
|
|
49
|
+
*/
|
|
50
|
+
static getHealth(): number;
|
|
51
|
+
protected abstract _getHealth(): number;
|
|
26
52
|
protected abstract _reset(): void;
|
|
27
53
|
/**
|
|
28
54
|
* Reset benchmark data (but not what is enabled).
|
|
@@ -43,14 +69,15 @@ export declare abstract class OINOBenchmark {
|
|
|
43
69
|
* @param method of the benchmark
|
|
44
70
|
*/
|
|
45
71
|
static startMetric(module: string, method: string): void;
|
|
46
|
-
protected abstract _endMetric(module: string, method: string): void;
|
|
72
|
+
protected abstract _endMetric(module: string, method: string, success: boolean): void;
|
|
47
73
|
/**
|
|
48
74
|
* Complete benchmark timing
|
|
49
75
|
*
|
|
50
76
|
* @param module of the benchmark
|
|
51
77
|
* @param method of the benchmark
|
|
78
|
+
* @param success indicates if the benchmark was successful
|
|
52
79
|
*/
|
|
53
|
-
static endMetric(module: string, method: string): void;
|
|
80
|
+
static endMetric(module: string, method: string, success?: boolean): void;
|
|
54
81
|
protected abstract _getMetric(module: string, method: string): number;
|
|
55
82
|
/**
|
|
56
83
|
* Get given benchmark data.
|
|
@@ -66,16 +93,16 @@ export declare abstract class OINOBenchmark {
|
|
|
66
93
|
*
|
|
67
94
|
*/
|
|
68
95
|
static getMetrics(): Record<string, number>;
|
|
69
|
-
protected abstract _trackMetric(module: string, method: string, value: number): void;
|
|
96
|
+
protected abstract _trackMetric(module: string, method: string, value: number, success: boolean): void;
|
|
70
97
|
/**
|
|
71
98
|
* Track a metric value
|
|
72
99
|
*
|
|
73
100
|
* @param module of the metric
|
|
74
101
|
* @param method of the metric
|
|
75
102
|
* @param value of the metric
|
|
76
|
-
*
|
|
103
|
+
* @param success indicates if the metric was successful
|
|
77
104
|
*/
|
|
78
|
-
static trackMetric(module: string, method: string, value: number): void;
|
|
105
|
+
static trackMetric(module: string, method: string, value: number, success?: boolean): void;
|
|
79
106
|
protected abstract _trackException(module: string, method: string, name: string, message: string, stack: string): void;
|
|
80
107
|
/**
|
|
81
108
|
* Track an exception
|
|
@@ -103,6 +130,8 @@ export declare class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
103
130
|
protected _benchmarkCount: Record<string, number>;
|
|
104
131
|
protected _benchmarkData: Record<string, number>;
|
|
105
132
|
protected _benchmarkStart: Record<string, number>;
|
|
133
|
+
protected _healthBenchmarks: number;
|
|
134
|
+
protected _healthFailures: number;
|
|
106
135
|
protected _exceptions: any[];
|
|
107
136
|
/**
|
|
108
137
|
* Reset benchmark data (but not what is enabled).
|
|
@@ -121,8 +150,9 @@ export declare class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
121
150
|
*
|
|
122
151
|
* @param module of the benchmark
|
|
123
152
|
* @param method of the benchmark
|
|
153
|
+
* @param success indicates if the benchmark was successful
|
|
124
154
|
*/
|
|
125
|
-
protected _endMetric(module: string, method: string): void;
|
|
155
|
+
protected _endMetric(module: string, method: string, success?: boolean): void;
|
|
126
156
|
/**
|
|
127
157
|
* Get given benchmark data.
|
|
128
158
|
*
|
|
@@ -136,7 +166,8 @@ export declare class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
136
166
|
*
|
|
137
167
|
*/
|
|
138
168
|
protected _getMetrics(): Record<string, number>;
|
|
139
|
-
protected _trackMetric(module: string, method: string, value: number): void;
|
|
169
|
+
protected _trackMetric(module: string, method: string, value: number, success?: boolean): void;
|
|
140
170
|
protected _trackException(module: string, method: string, name: string, message: string, stack: string): void;
|
|
141
171
|
protected _getExceptions(): any[];
|
|
172
|
+
protected _getHealth(): number;
|
|
142
173
|
}
|