File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
88import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core' ;
99import { TypeormInstrumentation } from '@opentelemetry/instrumentation-typeorm' ;
1010import { isEmpty } from 'omniboxd/utils/is-empty' ;
11+ import { Span } from '@opentelemetry/api' ;
12+ import { ServerResponse } from 'http' ;
1113
1214const env = process . env . ENV || 'unknown' ;
1315const serviceName = `omnibox-backend` ;
@@ -43,6 +45,12 @@ if (isTracingEnabled()) {
4345 ignoreIncomingRequestHook : ( req ) => {
4446 return excludedUrls . some ( ( url ) => req . url ?. includes ( url ) ) || false ;
4547 } ,
48+ responseHook : ( span : Span , response : ServerResponse ) => {
49+ const req = response . req as any ;
50+ if ( req . user ?. id ) {
51+ span . setAttribute ( 'user.id' , req . user . id ) ;
52+ }
53+ } ,
4654 } ) ,
4755 new ExpressInstrumentation ( ) ,
4856 new NestInstrumentation ( ) ,
You can’t perform that action at this time.
0 commit comments