@@ -99,7 +99,8 @@ class HLFConnection extends Connection {
9999 constructor ( connectionManager , connectionProfile , businessNetworkIdentifier , connectOptions , client , channel , caClient ) {
100100 super ( connectionManager , connectionProfile , businessNetworkIdentifier ) ;
101101 const method = 'constructor' ;
102- LOG . entry ( method , connectionManager , connectionProfile , businessNetworkIdentifier , connectOptions , client , channel , caClient ) ;
102+ // don't log the client, channel, caClient objects here they're too big
103+ LOG . entry ( method , connectionManager , connectionProfile , businessNetworkIdentifier , connectOptions ) ;
103104
104105 // Validate all the arguments.
105106 if ( ! connectOptions ) {
@@ -389,7 +390,8 @@ class HLFConnection extends Connection {
389390 } ;
390391 pollCCListener ( ) ;
391392
392- LOG . exit ( method , result ) ;
393+ // don't log the result object it's too large
394+ LOG . exit ( method ) ;
393395 return result ;
394396
395397 } )
@@ -412,7 +414,7 @@ class HLFConnection extends Connection {
412414 */
413415 async install ( securityContext , businessNetworkDefinition , installOptions ) {
414416 const method = 'install' ;
415- LOG . entry ( method , securityContext , businessNetworkDefinition , installOptions ) ;
417+ LOG . entry ( method , businessNetworkDefinition , installOptions ) ;
416418
417419 if ( ! businessNetworkDefinition ) {
418420 throw new Error ( 'businessNetworkDefinition not specified' ) ;
@@ -639,7 +641,7 @@ class HLFConnection extends Connection {
639641 */
640642 async start ( securityContext , businessNetworkName , businessNetworkVersion , startTransaction , startOptions ) {
641643 const method = 'start' ;
642- LOG . entry ( method , securityContext , businessNetworkName , startTransaction , startOptions ) ;
644+ LOG . entry ( method , businessNetworkName , startTransaction , startOptions ) ;
643645
644646 if ( ! businessNetworkName ) {
645647 throw new Error ( 'Business network name not specified' ) ;
@@ -785,7 +787,7 @@ class HLFConnection extends Connection {
785787 */
786788 ping ( securityContext ) {
787789 const method = 'ping' ;
788- LOG . entry ( method , securityContext ) ;
790+ LOG . entry ( method ) ;
789791
790792 // Check that a valid security context has been specified.
791793 HLFUtil . securityCheck ( securityContext ) ;
@@ -818,7 +820,7 @@ class HLFConnection extends Connection {
818820 */
819821 _checkRuntimeVersions ( securityContext ) {
820822 const method = '_checkRuntimeVersions' ;
821- LOG . entry ( method , securityContext ) ;
823+ LOG . entry ( method ) ;
822824
823825 return this . queryChainCode ( securityContext , 'ping' , [ ] )
824826 . then ( ( buffer ) => {
@@ -846,7 +848,7 @@ class HLFConnection extends Connection {
846848 */
847849 async queryChainCode ( securityContext , functionName , args ) {
848850 const method = 'queryChainCode' ;
849- LOG . entry ( method , securityContext , functionName , args ) ;
851+ LOG . entry ( method , functionName , args ) ;
850852
851853 if ( ! this . businessNetworkIdentifier ) {
852854 throw new Error ( 'No business network has been specified for this connection' ) ;
@@ -872,7 +874,10 @@ class HLFConnection extends Connection {
872874 }
873875
874876 let txId = this . client . newTransactionID ( ) ;
877+
878+ const t0 = Date . now ( ) ;
875879 let result = await this . queryHandler . queryChaincode ( txId , functionName , args ) ;
880+ LOG . perf ( method , 'Total duration for queryChaincode: ' , txId , t0 ) ;
876881 LOG . exit ( method , result ? result : null ) ;
877882 return result ? result : null ;
878883 }
@@ -889,7 +894,7 @@ class HLFConnection extends Connection {
889894 */
890895 async invokeChainCode ( securityContext , functionName , args , options = { } ) {
891896 const method = 'invokeChainCode' ;
892- LOG . entry ( method , securityContext , functionName , args , options ) ;
897+ LOG . entry ( method , functionName , args , options ) ;
893898
894899 // If commit has been set to false, we do not want to order the transaction or wait for any events.
895900 if ( options . commit === false ) {
@@ -928,6 +933,7 @@ class HLFConnection extends Connection {
928933 let eventHandler ;
929934 let validResponses ;
930935
936+ let t0 = Date . now ( ) ;
931937 try {
932938
933939 // initialize the channel if it hasn't been initialized already otherwise verification will fail.
@@ -944,7 +950,18 @@ class HLFConnection extends Connection {
944950 fcn : functionName ,
945951 args : args
946952 } ;
947- const results = await this . channel . sendTransactionProposal ( request ) ; // node sdk will target all peers on the channel that are endorsingPeer
953+ LOG . perf ( method , 'Total duration to initialize channel: ' , txId , t0 ) ;
954+ t0 = Date . now ( ) ;
955+
956+ let results ;
957+ try {
958+ results = await this . channel . sendTransactionProposal ( request ) ; // node sdk will target all peers on the channel that are endorsingPeer
959+ } catch ( error ) {
960+ LOG . error ( method , error ) ;
961+ throw new Error ( `Error received from sendTransactionProposal: ${ error } ` ) ;
962+ }
963+ LOG . perf ( method , 'Total duration for sendTransactionProposal: ' , txId , t0 ) ;
964+ t0 = Date . now ( ) ;
948965
949966 // Validate the endorsement results.
950967 LOG . debug ( method , `Received ${ results . length } result(s) from invoking the composer runtime chaincode` , results ) ;
@@ -970,11 +987,22 @@ class HLFConnection extends Connection {
970987 eventHandler = HLFConnection . createTxEventHandler ( this . eventHubs , txId . getTransactionID ( ) , this . commitTimeout ) ;
971988 eventHandler . startListening ( ) ;
972989 LOG . debug ( method , 'TxEventHandler started listening, sending valid responses to the orderer' ) ;
973- const response = await this . channel . sendTransaction ( {
974- proposalResponses : validResponses ,
975- proposal : proposal ,
976- header : header
977- } ) ;
990+ LOG . perf ( method , 'Total duration to prepare proposals for orderer: ' , txId , t0 ) ;
991+ t0 = Date . now ( ) ;
992+
993+ let response ;
994+ try {
995+ response = await this . channel . sendTransaction ( {
996+ proposalResponses : validResponses ,
997+ proposal : proposal ,
998+ header : header
999+ } ) ;
1000+ } catch ( error ) {
1001+ LOG . error ( method , error ) ;
1002+ throw new Error ( `Error received from sendTransaction: ${ error } ` ) ;
1003+ }
1004+ LOG . perf ( method , 'Total duration for sendTransaction: ' , txId , t0 ) ;
1005+ t0 = Date . now ( ) ;
9781006
9791007 // If the transaction was successful, wait for it to be committed.
9801008 LOG . debug ( method , 'Received response from orderer' , response ) ;
@@ -984,21 +1012,23 @@ class HLFConnection extends Connection {
9841012 throw new Error ( `Failed to send peer responses for transaction '${ txId . getTransactionID ( ) } ' to orderer. Response status '${ response . status } '` ) ;
9851013 }
9861014 await eventHandler . waitForEvents ( ) ;
1015+ LOG . perf ( method , 'Total duration for commit notification : ' , txId , t0 ) ;
9871016
9881017 LOG . exit ( method , result ) ;
9891018 return result ;
9901019
9911020 } catch ( error ) {
9921021 // Log first in case anything below fails and masks the original error
1022+ LOG . error ( method , `Failed to invoke business network with transaction id: ${ txId . getTransactionID ( ) } ` ) ;
9931023 LOG . error ( method , error ) ;
9941024
995- // Investigate proposal response results and log if they differ and rethrow
1025+ // Investigate proposal response results and log if they differ
9961026 if ( validResponses && validResponses . length >= 2 && ! this . channel . compareProposalResponseResults ( validResponses ) ) {
9971027 const warning = 'Peers did not agree, Read Write sets differed' ;
9981028 LOG . warn ( method , warning ) ;
9991029 }
10001030
1001- const newError = new Error ( ' Error trying invoke business network. ' + error ) ;
1031+ const newError = new Error ( ` Error trying invoke business network with transaction id ${ txId . getTransactionID ( ) } . ${ error } ` ) ;
10021032 throw newError ;
10031033 }
10041034 }
@@ -1020,7 +1050,7 @@ class HLFConnection extends Connection {
10201050 */
10211051 createIdentity ( securityContext , userID , options ) {
10221052 const method = 'createIdentity' ;
1023- LOG . entry ( method , securityContext , userID , options ) ;
1053+ LOG . entry ( method , userID , options ) ;
10241054
10251055 // Check that a valid security context has been specified.
10261056 HLFUtil . securityCheck ( securityContext ) ;
@@ -1095,7 +1125,7 @@ class HLFConnection extends Connection {
10951125 */
10961126 list ( securityContext ) {
10971127 const method = 'list' ;
1098- LOG . entry ( method , securityContext ) ;
1128+ LOG . entry ( method ) ;
10991129
11001130 // Check that a valid security context has been specified.
11011131 HLFUtil . securityCheck ( securityContext ) ;
@@ -1140,7 +1170,7 @@ class HLFConnection extends Connection {
11401170 */
11411171 async upgrade ( securityContext , businessNetworkName , businessNetworkVersion , upgradeOptions ) {
11421172 const method = 'upgrade' ;
1143- LOG . entry ( method , securityContext , businessNetworkName , upgradeOptions ) ;
1173+ LOG . entry ( method , businessNetworkName , upgradeOptions ) ;
11441174
11451175 if ( ! businessNetworkName ) {
11461176 throw new Error ( 'Business network name not specified' ) ;
0 commit comments