@@ -113,7 +113,7 @@ export class SDKClient {
113113 this . consensusNodeClientHistorgram = new Histogram ( {
114114 name : metricHistogramName ,
115115 help : 'Relay consensusnode mode type status cost histogram' ,
116- labelNames : [ 'mode' , 'type' , 'status' , 'caller' ] ,
116+ labelNames : [ 'mode' , 'type' , 'status' , 'caller' , 'interactingEntity' ] ,
117117 registers : [ register ]
118118 } ) ;
119119
@@ -146,7 +146,7 @@ export class SDKClient {
146146
147147 async getAccountBalance ( account : string , callerName : string , requestId ?: string ) : Promise < AccountBalance > {
148148 return this . executeQuery ( new AccountBalanceQuery ( )
149- . setAccountId ( AccountId . fromString ( account ) ) , this . clientMain , callerName , requestId ) ;
149+ . setAccountId ( AccountId . fromString ( account ) ) , this . clientMain , callerName , account , requestId ) ;
150150 }
151151
152152 async getAccountBalanceInTinyBar ( account : string , callerName : string , requestId ?: string ) : Promise < BigNumber > {
@@ -161,17 +161,17 @@ export class SDKClient {
161161
162162 async getAccountInfo ( address : string , callerName : string , requestId ?: string ) : Promise < AccountInfo > {
163163 return this . executeQuery ( new AccountInfoQuery ( )
164- . setAccountId ( AccountId . fromString ( address ) ) , this . clientMain , callerName , requestId ) ;
164+ . setAccountId ( AccountId . fromString ( address ) ) , this . clientMain , callerName , address , requestId ) ;
165165 }
166166
167167 async getContractByteCode ( shard : number | Long , realm : number | Long , address : string , callerName : string , requestId ?: string ) : Promise < Uint8Array > {
168168 return this . executeQuery ( new ContractByteCodeQuery ( )
169- . setContractId ( ContractId . fromEvmAddress ( shard , realm , address ) ) , this . clientMain , callerName , requestId ) ;
169+ . setContractId ( ContractId . fromEvmAddress ( shard , realm , address ) ) , this . clientMain , callerName , address , requestId ) ;
170170 }
171171
172172 async getContractBalance ( contract : string , callerName : string , requestId ?: string ) : Promise < AccountBalance > {
173173 return this . executeQuery ( new AccountBalanceQuery ( )
174- . setContractId ( ContractId . fromString ( contract ) ) , this . clientMain , callerName , requestId ) ;
174+ . setContractId ( ContractId . fromString ( contract ) ) , this . clientMain , callerName , contract , requestId ) ;
175175 }
176176
177177 async getContractBalanceInWeiBar ( account : string , callerName : string , requestId ?: string ) : Promise < BigNumber > {
@@ -211,7 +211,7 @@ export class SDKClient {
211211
212212 async getFileIdBytes ( address : string , callerName : string , requestId ?: string ) : Promise < Uint8Array > {
213213 return this . executeQuery ( new FileContentsQuery ( )
214- . setFileId ( address ) , this . clientMain , callerName , requestId ) ;
214+ . setFileId ( address ) , this . clientMain , callerName , address , requestId ) ;
215215 }
216216
217217 async getRecord ( transactionResponse : TransactionResponse ) {
@@ -221,6 +221,7 @@ export class SDKClient {
221221 async submitEthereumTransaction ( transactionBuffer : Uint8Array , callerName : string , requestId ?: string ) : Promise < TransactionResponse > {
222222 const ethereumTransactionData : EthereumTransactionData = EthereumTransactionData . fromBytes ( transactionBuffer ) ;
223223 const ethereumTransaction = new EthereumTransaction ( ) ;
224+ const interactingEntity = ethereumTransactionData . toJSON ( ) [ 'to' ] . toString ( ) ;
224225
225226 if ( ethereumTransactionData . toBytes ( ) . length <= 5120 ) {
226227 ethereumTransaction . setEthereumData ( ethereumTransactionData . toBytes ( ) ) ;
@@ -238,7 +239,7 @@ export class SDKClient {
238239 const tinybarsGasFee = await this . getTinyBarGasFee ( 'eth_sendRawTransaction' ) ;
239240 ethereumTransaction . setMaxTransactionFee ( Hbar . fromTinybars ( Math . floor ( tinybarsGasFee * constants . BLOCK_GAS_LIMIT ) ) ) ;
240241
241- return this . executeTransaction ( ethereumTransaction , callerName , requestId ) ;
242+ return this . executeTransaction ( ethereumTransaction , callerName , interactingEntity , requestId ) ;
242243 }
243244
244245 async submitContractCallQuery ( to : string , data : string , gas : number , from : string , callerName : string , requestId ?: string ) : Promise < ContractFunctionResult > {
@@ -265,7 +266,7 @@ export class SDKClient {
265266 . setPaymentTransactionId ( TransactionId . generate ( this . clientMain . operatorAccountId ) ) ;
266267 }
267268
268- return this . executeQuery ( contractCallQuery , this . clientMain , callerName , requestId ) ;
269+ return this . executeQuery ( contractCallQuery , this . clientMain , callerName , to , requestId ) ;
269270 }
270271
271272 async increaseCostAndRetryExecution ( query : Query < any > , baseCost : Hbar , client : Client , maxRetries : number , currentRetry : number , requestId ?: string ) {
@@ -304,7 +305,7 @@ export class SDKClient {
304305 ) ;
305306 } ;
306307
307- private executeQuery = async ( query : Query < any > , client : Client , callerName : string , requestId ?: string ) => {
308+ private executeQuery = async ( query : Query < any > , client : Client , callerName : string , interactingEntity : string , requestId ?: string ) => {
308309 const requestIdPrefix = formatRequestIdMessage ( requestId ) ;
309310 const currentDateNow = Date . now ( ) ;
310311 try {
@@ -332,7 +333,8 @@ export class SDKClient {
332333 query . constructor . name ,
333334 Status . Success ,
334335 cost ,
335- callerName ) ;
336+ callerName ,
337+ interactingEntity ) ;
336338 return resp ;
337339 }
338340 catch ( e : any ) {
@@ -343,7 +345,8 @@ export class SDKClient {
343345 query . constructor . name ,
344346 sdkClientError . status ,
345347 cost ,
346- callerName ) ;
348+ callerName ,
349+ interactingEntity ) ;
347350 this . logger . trace ( `${ requestIdPrefix } ${ query . paymentTransactionId } ${ callerName } ${ query . constructor . name } status: ${ sdkClientError . status } (${ sdkClientError . status . _code } ), cost: ${ query . _queryPayment } ` ) ;
348351 if ( cost ) {
349352 this . hbarLimiter . addExpense ( cost , currentDateNow ) ;
@@ -365,7 +368,7 @@ export class SDKClient {
365368 }
366369 } ;
367370
368- private executeTransaction = async ( transaction : Transaction , callerName : string , requestId ?: string ) : Promise < TransactionResponse > => {
371+ private executeTransaction = async ( transaction : Transaction , callerName : string , interactingEntity : string , requestId ?: string ) : Promise < TransactionResponse > => {
369372 const transactionType = transaction . constructor . name ;
370373 const requestIdPrefix = formatRequestIdMessage ( requestId ) ;
371374 const currentDateNow = Date . now ( ) ;
@@ -400,7 +403,8 @@ export class SDKClient {
400403 transactionType ,
401404 sdkClientError . status ,
402405 transactionFee . toTinybars ( ) . toNumber ( ) ,
403- callerName ) ;
406+ callerName ,
407+ interactingEntity ) ;
404408
405409 this . hbarLimiter . addExpense ( transactionFee . toTinybars ( ) . toNumber ( ) , currentDateNow ) ;
406410 } catch ( err : any ) {
@@ -417,7 +421,7 @@ export class SDKClient {
417421 }
418422 } ;
419423
420- async executeGetTransactionRecord ( resp : TransactionResponse , transactionName : string , callerName : string , requestId ?: string ) : Promise < TransactionRecord > {
424+ async executeGetTransactionRecord ( resp : TransactionResponse , transactionName : string , callerName : string , interactingEntity : string , requestId ?: string ) : Promise < TransactionRecord > {
421425 const requestIdPrefix = formatRequestIdMessage ( requestId ) ;
422426 const currentDateNow = Date . now ( ) ;
423427 try {
@@ -438,7 +442,8 @@ export class SDKClient {
438442 transactionName ,
439443 transactionRecord . receipt . status ,
440444 cost ,
441- callerName ) ;
445+ callerName ,
446+ interactingEntity ) ;
442447
443448 this . hbarLimiter . addExpense ( cost , currentDateNow ) ;
444449
@@ -463,7 +468,8 @@ export class SDKClient {
463468 transactionName ,
464469 sdkClientError . status ,
465470 transactionFee . toTinybars ( ) . toNumber ( ) ,
466- callerName ) ;
471+ callerName ,
472+ interactingEntity ) ;
467473
468474 this . hbarLimiter . addExpense ( transactionFee . toTinybars ( ) . toNumber ( ) , currentDateNow ) ;
469475 } catch ( err : any ) {
@@ -481,13 +487,14 @@ export class SDKClient {
481487 }
482488 } ;
483489
484- private captureMetrics = ( mode , type , status , cost , caller ) => {
490+ private captureMetrics = ( mode , type , status , cost , caller , interactingEntity ) => {
485491 const resolvedCost = cost ? cost : 0 ;
486492 this . consensusNodeClientHistorgram . labels (
487493 mode ,
488494 type ,
489495 status ,
490- caller )
496+ caller ,
497+ interactingEntity )
491498 . observe ( resolvedCost ) ;
492499 } ;
493500
0 commit comments