feat(ops): 增加运行时性能看板

This commit is contained in:
2026-07-08 17:47:36 +08:00
parent 58c98a3a3d
commit 15653b5b35
19 changed files with 933 additions and 2 deletions

View File

@@ -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 });
}),
);
}