Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "4.0.1",
"version": "4.1.0",
"packages": [
"packages/*"
],
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-auth",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs auth package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -38,9 +38,9 @@
"jsonwebtoken": "^9.0.0"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-cache": "^4.0.0",
"@multiversx/sdk-nestjs-common": "^4.0.0",
"@multiversx/sdk-nestjs-monitoring": "^4.0.0",
"@multiversx/sdk-nestjs-cache": "^4.1.0",
"@multiversx/sdk-nestjs-common": "^4.1.0",
"@multiversx/sdk-nestjs-monitoring": "^4.1.0",
"@nestjs/common": "^10.x"
},
"publishConfig": {
Expand Down
8 changes: 4 additions & 4 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-cache",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs cache package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -40,9 +40,9 @@
"uuid": "^8.3.2"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-common": "^4.0.0",
"@multiversx/sdk-nestjs-monitoring": "^4.0.0",
"@multiversx/sdk-nestjs-redis": "^4.0.0",
"@multiversx/sdk-nestjs-common": "^4.1.0",
"@multiversx/sdk-nestjs-monitoring": "^4.1.0",
"@multiversx/sdk-nestjs-redis": "^4.1.0",
"@nestjs/common": "^10.x",
"@nestjs/core": "^10.x"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-common",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs common package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
"winston": "^3.7.2"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-monitoring": "^4.0.0",
"@multiversx/sdk-nestjs-monitoring": "^4.1.0",
"@nestjs/common": "^10.x",
"@nestjs/config": "^3.x",
"@nestjs/core": "^10.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/elastic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-elastic",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs elastic package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -31,7 +31,7 @@
"typescript": "^4.3.5"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-http": "^4.0.0",
"@multiversx/sdk-nestjs-http": "^4.1.0",
"@nestjs/common": "^10.x"
},
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-http",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs http package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -38,8 +38,8 @@
"axios": "^1.7.4"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-common": "^4.0.0",
"@multiversx/sdk-nestjs-monitoring": "^4.0.0",
"@multiversx/sdk-nestjs-common": "^4.1.0",
"@multiversx/sdk-nestjs-monitoring": "^4.1.0",
"@nestjs/common": "^10.x",
"@nestjs/core": "^10.x"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/monitoring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-monitoring",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs monitoring package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/monitoring/src/interceptors/logging.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { PerformanceProfiler } from "../profilers/performance.profiler";
export class LoggingInterceptor implements NestInterceptor {
constructor(
private readonly metricsService: MetricsService,
private readonly onRequest?: (apiFunction: string, durationMs: number, context: ExecutionContext) => void,
) { }

intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
Expand Down Expand Up @@ -38,13 +39,21 @@ export class LoggingInterceptor implements NestInterceptor {
const res = http.getResponse();

this.metricsService.setApiCall(apiFunction, origin, res.statusCode, profiler.duration);

if (this.onRequest) {
this.onRequest(apiFunction, profiler.duration, context);
}
}),
catchError(err => {
profiler.stop();

const statusCode = err.status ?? HttpStatus.INTERNAL_SERVER_ERROR;
this.metricsService.setApiCall(apiFunction, origin, statusCode, profiler.duration);

if (this.onRequest) {
this.onRequest(apiFunction, profiler.duration, context);
}

return throwError(() => err);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { CpuProfiler } from "../profilers/cpu.profiler";
@Injectable()
export class RequestCpuTimeInterceptor implements NestInterceptor {
constructor(
private readonly metricsService: MetricsService
private readonly metricsService: MetricsService,
private readonly onRequest?: (apiFunction: string, durationMs: number, context: ExecutionContext) => void,
) { }

intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
Expand All @@ -29,6 +30,10 @@ export class RequestCpuTimeInterceptor implements NestInterceptor {
const duration = profiler.stop();
this.metricsService.setApiCpuTime(apiFunction, duration);

if (this.onRequest) {
this.onRequest(apiFunction, duration, context);
}

if (!request.res.headersSent) {
request.res.set('X-Request-Cpu-Time', duration);
}
Expand All @@ -37,10 +42,13 @@ export class RequestCpuTimeInterceptor implements NestInterceptor {
const duration = profiler.stop();
this.metricsService.setApiCpuTime(apiFunction, duration);

if (this.onRequest) {
this.onRequest(apiFunction, duration, context);
}

if (!request.res.headersSent) {
request.res.set('X-Request-Cpu-Time', duration);
}

return throwError(() => err);
})
);
Expand Down
4 changes: 2 additions & 2 deletions packages/rabbitmq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-rabbitmq",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs rabbitmq client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -37,7 +37,7 @@
"uuid": "^8.3.2"
},
"peerDependencies": {
"@multiversx/sdk-nestjs-common": "^4.0.0",
"@multiversx/sdk-nestjs-common": "^4.1.0",
"@nestjs/common": "^10.x"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/redis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-redis",
"version": "4.0.1",
"version": "4.1.0",
"description": "Multiversx SDK Nestjs redis client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down