Skip to content

Commit

Permalink
Merge pull request #23 from kaleido-io/rpc-info
Browse files Browse the repository at this point in the history
Update info logging to include method and time
  • Loading branch information
nguyer authored Aug 31, 2022
2 parents 6e97617 + 18919ff commit 57aaec9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/rpcbackend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"sync/atomic"
"time"

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

0 comments on commit 57aaec9

Please sign in to comment.