Skip to content

Commit

Permalink
add statemanager.CallRaw span
Browse files Browse the repository at this point in the history
This allows for the chain.Sync trace to be connected to the
entire chain sync operation, when viewing in Jaeger.
  • Loading branch information
lanzafame committed Oct 28, 2019
1 parent 705637b commit 0822bda
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 0822bda

Please sign in to comment.