@kronos-integration/interceptor 10.2.34 → 10.2.35
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/LICENSE +1 -1
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/stats-collector-interceptor.mjs +24 -18
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/@kronos-integration/interceptor)
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
|
-
[](https://bundlejs.com/?q=@kronos-integration/interceptor)
|
|
4
4
|
[](https://npmjs.org/package/@kronos-integration/interceptor)
|
|
5
5
|
[](https://github.com/Kronos-Integration/interceptor/issues)
|
|
6
6
|
[](https://actions-badge.atrox.dev/Kronos-Integration/interceptor/goto)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/interceptor",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.35",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@kronos-integration/test-interceptor": "^7.0.27",
|
|
39
|
-
"ava": "^5.1
|
|
40
|
-
"c8": "^
|
|
41
|
-
"documentation": "^14.0.
|
|
42
|
-
"semantic-release": "^
|
|
39
|
+
"ava": "^5.3.1",
|
|
40
|
+
"c8": "^8.0.0",
|
|
41
|
+
"documentation": "^14.0.2",
|
|
42
|
+
"semantic-release": "^21.0.5"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
45
|
+
"node": ">=20.3.1"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/Kronos-Integration/interceptor
|
|
49
|
+
"url": "https://github.com/Kronos-Integration/interceptor"
|
|
50
50
|
},
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/Kronos-Integration/interceptor/issues"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Interceptor } from './interceptor.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Interceptor to collect processing time, number of
|
|
@@ -12,39 +12,45 @@ 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
|
+
|
|
15
21
|
reset() {
|
|
16
|
-
this
|
|
17
|
-
this
|
|
18
|
-
this
|
|
19
|
-
this
|
|
20
|
-
this
|
|
22
|
+
this.#numberOfRequests = 0;
|
|
23
|
+
this.#numberOfFailedRequests = 0;
|
|
24
|
+
this.#minRequestProcessingTime = Number.MAX_VALUE;
|
|
25
|
+
this.#maxRequestProcessingTime = 0;
|
|
26
|
+
this.#totalRequestProcessingTime = 0;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
get numberOfRequests() {
|
|
24
|
-
return this
|
|
30
|
+
return this.#numberOfRequests;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
get numberOfFailedRequests() {
|
|
28
|
-
return this
|
|
34
|
+
return this.#numberOfFailedRequests;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
get maxRequestProcessingTime() {
|
|
32
|
-
return this
|
|
38
|
+
return this.#maxRequestProcessingTime;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
get minRequestProcessingTime() {
|
|
36
|
-
return this
|
|
42
|
+
return this.#minRequestProcessingTime;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
get totalRequestProcessingTime() {
|
|
40
|
-
return this
|
|
46
|
+
return this.#totalRequestProcessingTime;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
50
|
* Logs the time the requests takes
|
|
45
51
|
*/
|
|
46
52
|
async receive(endpoint,...args) {
|
|
47
|
-
this
|
|
53
|
+
this.#numberOfRequests += 1;
|
|
48
54
|
|
|
49
55
|
const start = new Date();
|
|
50
56
|
|
|
@@ -52,20 +58,20 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
52
58
|
const response = await this.connected.receive(...args);
|
|
53
59
|
const now = new Date();
|
|
54
60
|
const pt = now - start;
|
|
55
|
-
this
|
|
61
|
+
this.#totalRequestProcessingTime += pt;
|
|
56
62
|
|
|
57
|
-
if (pt > this
|
|
58
|
-
this
|
|
63
|
+
if (pt > this.#maxRequestProcessingTime) {
|
|
64
|
+
this.#maxRequestProcessingTime = pt;
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
if (pt < this
|
|
62
|
-
this
|
|
67
|
+
if (pt < this.#minRequestProcessingTime) {
|
|
68
|
+
this.#minRequestProcessingTime = pt;
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
endpoint.logger.debug(`took ${pt} ms for ${[...args]}`);
|
|
66
72
|
return response;
|
|
67
73
|
} catch (err) {
|
|
68
|
-
this
|
|
74
|
+
this.#numberOfFailedRequests += 1;
|
|
69
75
|
throw err;
|
|
70
76
|
}
|
|
71
77
|
}
|