Merge pull request #485 from lanzafame/feat/connect-chain-sync-trace

add statemanager.CallRaw span
This commit is contained in:
Whyrusleeping 2019-10-30 10:57:09 -07:00 committed by GitHub
commit 790ac7b510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/ipfs/go-cid"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
@ -14,6 +15,9 @@ import (
)
func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate cid.Cid, r vm.Rand, bheight uint64) (*types.MessageReceipt, error) {
ctx, span := trace.StartSpan(ctx, "statemanager.CallRaw")
defer span.End()
vmi, err := vm.NewVM(bstate, bheight, r, actors.NetworkAddress, sm.cs.Blockstore())
if err != nil {
return nil, xerrors.Errorf("failed to set up vm: %w", err)
@ -29,6 +33,14 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
msg.Value = types.NewInt(0)
}
if span.IsRecordingEvents() {
span.AddAttributes(
trace.Int64Attribute("gas_limit", int64(msg.GasLimit.Uint64())),
trace.Int64Attribute("gas_price", int64(msg.GasPrice.Uint64())),
trace.StringAttribute("value", msg.Value.String()),
)
}
fromActor, err := vmi.StateTree().GetActor(msg.From)
if err != nil {
return nil, xerrors.Errorf("call raw get actor: %s", err)