@kronos-integration/interceptor 12.1.3 → 12.1.4
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.
package/package.json
CHANGED
|
@@ -12,45 +12,19 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
12
12
|
return 'collect-request-stats';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
#numberOfRequests;
|
|
16
|
-
#numberOfFailedRequests;;
|
|
17
|
-
#minRequestProcessingTime;;
|
|
18
|
-
#maxRequestProcessingTime;
|
|
19
|
-
#totalRequestProcessingTime;
|
|
20
|
-
|
|
21
15
|
reset() {
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
this
|
|
25
|
-
this
|
|
26
|
-
this
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get numberOfRequests() {
|
|
30
|
-
return this.#numberOfRequests;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get numberOfFailedRequests() {
|
|
34
|
-
return this.#numberOfFailedRequests;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get maxRequestProcessingTime() {
|
|
38
|
-
return this.#maxRequestProcessingTime;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get minRequestProcessingTime() {
|
|
42
|
-
return this.#minRequestProcessingTime;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get totalRequestProcessingTime() {
|
|
46
|
-
return this.#totalRequestProcessingTime;
|
|
16
|
+
this.numberOfRequests = 0;
|
|
17
|
+
this.numberOfFailedRequests = 0;
|
|
18
|
+
this.minRequestProcessingTime = Number.MAX_VALUE;
|
|
19
|
+
this.maxRequestProcessingTime = 0;
|
|
20
|
+
this.totalRequestProcessingTime = 0;
|
|
47
21
|
}
|
|
48
22
|
|
|
49
23
|
/**
|
|
50
24
|
* Logs the time the requests takes
|
|
51
25
|
*/
|
|
52
26
|
async receive(endpoint,...args) {
|
|
53
|
-
this
|
|
27
|
+
this.numberOfRequests += 1;
|
|
54
28
|
|
|
55
29
|
const start = Date.now();
|
|
56
30
|
|
|
@@ -58,20 +32,20 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
58
32
|
const response = await this.connected.receive(...args);
|
|
59
33
|
const now = Date.now();
|
|
60
34
|
const pt = now - start;
|
|
61
|
-
this
|
|
35
|
+
this.totalRequestProcessingTime += pt;
|
|
62
36
|
|
|
63
|
-
if (pt > this
|
|
64
|
-
this
|
|
37
|
+
if (pt > this.maxRequestProcessingTime) {
|
|
38
|
+
this.maxRequestProcessingTime = pt;
|
|
65
39
|
}
|
|
66
40
|
|
|
67
|
-
if (pt < this
|
|
68
|
-
this
|
|
41
|
+
if (pt < this.minRequestProcessingTime) {
|
|
42
|
+
this.minRequestProcessingTime = pt;
|
|
69
43
|
}
|
|
70
44
|
|
|
71
45
|
endpoint.logger.debug(level=>`took ${pt} ms for ${[...args]}`);
|
|
72
46
|
return response;
|
|
73
47
|
} catch (err) {
|
|
74
|
-
this
|
|
48
|
+
this.numberOfFailedRequests += 1;
|
|
75
49
|
throw err;
|
|
76
50
|
}
|
|
77
51
|
}
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
* processed and failed requests.
|
|
4
4
|
*/
|
|
5
5
|
export class StatsCollectorInterceptor extends Interceptor {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
numberOfRequests: number;
|
|
7
|
+
numberOfFailedRequests: number;
|
|
8
|
+
minRequestProcessingTime: number;
|
|
9
|
+
maxRequestProcessingTime: number;
|
|
10
|
+
totalRequestProcessingTime: number;
|
|
11
11
|
/**
|
|
12
12
|
* Logs the time the requests takes
|
|
13
13
|
*/
|
|
14
14
|
receive(endpoint: any, ...args: any[]): Promise<any>;
|
|
15
|
-
#private;
|
|
16
15
|
}
|
|
17
16
|
import { Interceptor } from './interceptor.mjs';
|