Skip to content

Commit 57aaec9

Browse files
authored
Merge pull request #23 from kaleido-io/rpc-info
Update info logging to include method and time
2 parents 6e97617 + 18919ff commit 57aaec9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/rpcbackend/backend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"sync/atomic"
24+
"time"
2425

2526
"github.com/go-resty/resty/v2"
2627
"github.com/hyperledger/firefly-common/pkg/fftypes"
@@ -133,6 +134,7 @@ func (rc *RPCClient) SyncRequest(ctx context.Context, rpcReq *RPCRequest) (rpcRe
133134
jsonInput, _ := json.Marshal(rpcReq)
134135
log.L(ctx).Tracef("RPC[%s] INPUT: %s", rpcTraceID, jsonInput)
135136
}
137+
rpcStartTime := time.Now()
136138
res, err := rc.client.R().
137139
SetContext(ctx).
138140
SetBody(beReq).
@@ -158,7 +160,7 @@ func (rc *RPCClient) SyncRequest(ctx context.Context, rpcReq *RPCRequest) (rpcRe
158160
err := fmt.Errorf(rpcRes.Message())
159161
return rpcRes, err
160162
}
161-
log.L(ctx).Infof("RPC[%s] <-- [%d] OK", rpcTraceID, res.StatusCode())
163+
log.L(ctx).Infof("RPC[%s] <-- %s [%d] OK (%.2fms)", rpcTraceID, rpcReq.Method, res.StatusCode(), float64(time.Since(rpcStartTime))/float64(time.Millisecond))
162164
if rpcRes.Result == nil {
163165
// We don't want a result for errors, but a null success response needs to go in there
164166
rpcRes.Result = fftypes.JSONAnyPtr(fftypes.NullString)

0 commit comments

Comments
 (0)