@kronos-integration/interceptor 12.1.4 → 12.1.5
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Interceptor } from
|
|
1
|
+
import { Interceptor } from "./interceptor.mjs";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Interceptor to collect processing time, number of
|
|
@@ -9,7 +9,7 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
9
9
|
* @return {string} 'collect-request-stats'
|
|
10
10
|
*/
|
|
11
11
|
static get name() {
|
|
12
|
-
return
|
|
12
|
+
return "collect-request-stats";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
reset() {
|
|
@@ -23,13 +23,13 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
23
23
|
/**
|
|
24
24
|
* Logs the time the requests takes
|
|
25
25
|
*/
|
|
26
|
-
async receive(endpoint
|
|
26
|
+
async receive(endpoint, next, ...args) {
|
|
27
27
|
this.numberOfRequests += 1;
|
|
28
28
|
|
|
29
29
|
const start = Date.now();
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
|
-
const response = await
|
|
32
|
+
const response = await next(...args);
|
|
33
33
|
const now = Date.now();
|
|
34
34
|
const pt = now - start;
|
|
35
35
|
this.totalRequestProcessingTime += pt;
|
|
@@ -42,7 +42,7 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
42
42
|
this.minRequestProcessingTime = pt;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
endpoint.logger.debug(level
|
|
45
|
+
endpoint.logger.debug(level => `took ${pt} ms for ${[...args]}`);
|
|
46
46
|
return response;
|
|
47
47
|
} catch (err) {
|
|
48
48
|
this.numberOfFailedRequests += 1;
|
|
@@ -11,6 +11,6 @@ export class StatsCollectorInterceptor extends Interceptor {
|
|
|
11
11
|
/**
|
|
12
12
|
* Logs the time the requests takes
|
|
13
13
|
*/
|
|
14
|
-
receive(endpoint: any, ...args: any[]): Promise<any>;
|
|
14
|
+
receive(endpoint: any, next: any, ...args: any[]): Promise<any>;
|
|
15
15
|
}
|
|
16
|
-
import { Interceptor } from
|
|
16
|
+
import { Interceptor } from "./interceptor.mjs";
|