@@ -3,12 +3,13 @@ import { Observable, throwError } from "rxjs";
33import { catchError , tap } from "rxjs/operators" ;
44import { MetricsService } from "../metrics" ;
55import { PerformanceProfiler } from "../profilers/performance.profiler" ;
6+ import { LoggingInterceptorContext } from "./entities/logging.interceptor.context" ;
67
78@Injectable ( )
89export class LoggingInterceptor implements NestInterceptor {
910 constructor (
1011 private readonly metricsService : MetricsService ,
11- private readonly onRequest ?: ( apiFunction : string , durationMs : number , context : ExecutionContext ) => void ,
12+ private readonly onRequest ?: ( context : LoggingInterceptorContext ) => void ,
1213 ) { }
1314
1415 intercept ( context : ExecutionContext , next : CallHandler ) : Observable < any > {
@@ -41,7 +42,13 @@ export class LoggingInterceptor implements NestInterceptor {
4142 this . metricsService . setApiCall ( apiFunction , origin , res . statusCode , profiler . duration ) ;
4243
4344 if ( this . onRequest ) {
44- this . onRequest ( apiFunction , profiler . duration , context ) ;
45+ this . onRequest ( new LoggingInterceptorContext ( {
46+ apiFunction,
47+ durationMs : profiler . duration ,
48+ origin,
49+ statusCode : res . statusCode ,
50+ context,
51+ } ) ) ;
4552 }
4653 } ) ,
4754 catchError ( err => {
@@ -51,7 +58,13 @@ export class LoggingInterceptor implements NestInterceptor {
5158 this . metricsService . setApiCall ( apiFunction , origin , statusCode , profiler . duration ) ;
5259
5360 if ( this . onRequest ) {
54- this . onRequest ( apiFunction , profiler . duration , context ) ;
61+ this . onRequest ( new LoggingInterceptorContext ( {
62+ apiFunction,
63+ durationMs : profiler . duration ,
64+ origin,
65+ statusCode,
66+ context,
67+ } ) ) ;
5568 }
5669
5770 return throwError ( ( ) => err ) ;
0 commit comments