feat(ops): 增加运行时性能看板
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { CallHandler, ExecutionContext, Injectable, Logger, NestInterceptor } from '@nestjs/common';
|
||||
import { finalize, Observable } from 'rxjs';
|
||||
import { recordSlowRequest } from '../../modules/ops/ops-runtime.store';
|
||||
|
||||
const DEFAULT_API_SLOW_REQUEST_MS = 1000;
|
||||
|
||||
@@ -25,6 +26,7 @@ export class ApiTimingInterceptor implements NestInterceptor {
|
||||
const method = request.method ?? 'UNKNOWN';
|
||||
const url = request.originalUrl ?? request.url ?? 'unknown-url';
|
||||
this.logger.warn(`Slow API request: ${method} ${url} ${durationMs}ms`);
|
||||
recordSlowRequest({ method, url, durationMs, thresholdMs: this.thresholdMs });
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user