File tree Expand file tree Collapse file tree 1 file changed +21
-13
lines changed
packages/client/lib/client Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -1097,20 +1097,28 @@ export default class RedisClient<
10971097 } ;
10981098
10991099 const promise = this . _self . #queue. addCommand < T > ( args , opts ) ;
1100- OTelMetrics . instance . recordPendingRequests ( 1 , clientAttributes ) ;
11011100
1102- const trackedPromise = promise . then ( ( reply ) => {
1103- recordOperation ( ) ;
1104- OTelMetrics . instance . recordPendingRequests ( - 1 , clientAttributes ) ;
1105- return reply ;
1106- } ) . catch ( ( err ) => {
1107- recordOperation ( err ) ;
1108- OTelMetrics . instance . recordPendingRequests ( - 1 , clientAttributes ) ;
1109- throw err ;
1110- } ) ;
1111-
1112- this . _self . #scheduleWrite( ) ;
1113- return trackedPromise ;
1101+ if ( OTelMetrics . isInitialized ( ) ) {
1102+ OTelMetrics . instance . recordPendingRequests ( 1 , clientAttributes ) ;
1103+
1104+ const trackedPromise = promise
1105+ . then ( ( reply ) => {
1106+ recordOperation ( ) ;
1107+ OTelMetrics . instance . recordPendingRequests ( - 1 , clientAttributes ) ;
1108+ return reply ;
1109+ } )
1110+ . catch ( ( err ) => {
1111+ recordOperation ( err ) ;
1112+ OTelMetrics . instance . recordPendingRequests ( - 1 , clientAttributes ) ;
1113+ throw err ;
1114+ } ) ;
1115+
1116+ this . _self . #scheduleWrite( ) ;
1117+ return trackedPromise ;
1118+ } else {
1119+ this . _self . #scheduleWrite( ) ;
1120+ return promise ;
1121+ }
11141122 }
11151123
11161124 async SELECT ( db : number ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments