Skip to content

Commit

Permalink
Merge pull request filecoin-project#485 from lanzafame/feat/connect-c…
Browse files Browse the repository at this point in the history
…hain-sync-trace

add statemanager.CallRaw span
  • Loading branch information
whyrusleeping committed Oct 30, 2019
2 parents 413314b + 0822bda commit 790ac7b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions chain/stmgr/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 790ac7b

Please sign in to comment.