@@ -21,7 +21,7 @@ import { BasicCommandParser, CommandParser } from './parser';
2121import SingleEntryCache from '../single-entry-cache' ;
2222import { version } from '../../package.json'
2323import EnterpriseMaintenanceManager , { MaintenanceUpdate , MovingEndpointType } from './enterprise-maintenance-manager' ;
24- import { OTelClientAttributes , OTelMetrics } from '../opentelemetry' ;
24+ import { OTelClientAttributes } from '../opentelemetry' ;
2525
2626export interface RedisClientOptions <
2727 M extends RedisModules = RedisModules ,
@@ -652,7 +652,7 @@ export default class RedisClient<
652652 . addCommand ( cmd , {
653653 chainId,
654654 asap
655- } )
655+ } , this . _getClientOTelAttributes ( ) )
656656 . catch ( errorHandler )
657657 ) ;
658658 }
@@ -1076,17 +1076,12 @@ export default class RedisClient<
10761076 args : ReadonlyArray < RedisArgument > ,
10771077 options ?: CommandOptions
10781078 ) : Promise < T > {
1079- const clientAttributes = this . _self . _getClientOTelAttributes ( ) ;
1080- const recordOperation = OTelMetrics . instance . createRecordOperationDuration ( args , clientAttributes ) ;
1081-
10821079 if ( ! this . _self . #socket. isOpen ) {
1083- recordOperation ( new ClientClosedError ( ) ) ;
10841080 return Promise . reject ( new ClientClosedError ( ) ) ;
10851081 } else if (
10861082 ! this . _self . #socket. isReady &&
10871083 this . _self . #options. disableOfflineQueue
10881084 ) {
1089- recordOperation ( new ClientOfflineError ( ) ) ;
10901085 return Promise . reject ( new ClientOfflineError ( ) ) ;
10911086 }
10921087
@@ -1096,29 +1091,11 @@ export default class RedisClient<
10961091 ...options ,
10971092 } ;
10981093
1099- const promise = this . _self . #queue. addCommand < T > ( args , opts ) ;
1100-
1101- if ( OTelMetrics . isInitialized ( ) ) {
1102- OTelMetrics . instance . recordPendingRequests ( 1 , clientAttributes ) ;
1094+ const promise = this . _self . #queue. addCommand < T > ( args , opts , this . _self . _getClientOTelAttributes ( ) ) ;
11031095
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- } ) ;
11151096
1116- this . _self . #scheduleWrite( ) ;
1117- return trackedPromise ;
1118- } else {
1119- this . _self . #scheduleWrite( ) ;
1120- return promise ;
1121- }
1097+ this . _self . #scheduleWrite( ) ;
1098+ return promise ;
11221099 }
11231100
11241101 async SELECT ( db : number ) : Promise < void > {
@@ -1354,20 +1331,20 @@ export default class RedisClient<
13541331 const typeMapping = this . _commandOptions ?. typeMapping ;
13551332 const chainId = Symbol ( 'MULTI Chain' ) ;
13561333 const promises = [
1357- this . _self . #queue. addCommand ( [ 'MULTI' ] , { chainId } ) ,
1334+ this . _self . #queue. addCommand ( [ 'MULTI' ] , { chainId } , this . _self . _getClientOTelAttributes ( ) ) ,
13581335 ] ;
13591336
13601337 for ( const { args } of commands ) {
13611338 promises . push (
13621339 this . _self . #queue. addCommand ( args , {
13631340 chainId,
13641341 typeMapping
1365- } )
1342+ } , this . _self . _getClientOTelAttributes ( ) )
13661343 ) ;
13671344 }
13681345
13691346 promises . push (
1370- this . _self . #queue. addCommand ( [ 'EXEC' ] , { chainId } )
1347+ this . _self . #queue. addCommand ( [ 'EXEC' ] , { chainId } , this . _self . _getClientOTelAttributes ( ) )
13711348 ) ;
13721349
13731350 this . _self . #scheduleWrite( ) ;
@@ -1543,7 +1520,7 @@ export default class RedisClient<
15431520 this . _self . #credentialsSubscription = null ;
15441521 return this . _self . #socket. quit ( async ( ) => {
15451522 clearTimeout ( this . _self . #pingTimer) ;
1546- const quitPromise = this . _self . #queue. addCommand < string > ( [ 'QUIT' ] ) ;
1523+ const quitPromise = this . _self . #queue. addCommand < string > ( [ 'QUIT' ] , undefined , this . _self . _getClientOTelAttributes ( ) ) ;
15471524 this . _self . #scheduleWrite( ) ;
15481525 return quitPromise ;
15491526 } ) ;
0 commit comments