Skip to content

Commit

Permalink
feat(otel): more info to Run span (errors and evm flags)
Browse files Browse the repository at this point in the history
  • Loading branch information
youben11 committed Feb 26, 2024
1 parent 83292c8 commit 95523dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/zama-ai/fhevm-go/fhevm"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
)

// Config are the configuration options for the Interpreter
Expand Down Expand Up @@ -123,10 +124,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
// considered a revert-and-consume-all-gas operation except for
// ErrExecutionReverted which means revert-and-keep-gas-left.
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
ctx, span := otel.Tracer("fhevm").Start(context.TODO(), "InterpreterRun")
ctx, runSpan := otel.Tracer("fhevm").Start(context.TODO(), "InterpreterRun")
runSpan.SetAttributes(attribute.KeyValue{Key: "eth_call", Value: attribute.BoolValue(in.evm.isEthCall)})
runSpan.SetAttributes(attribute.KeyValue{Key: "gas_estimation", Value: attribute.BoolValue(in.evm.isGasEstimation)})
// set the execution context to be used by ops
in.evm.executionContext = ctx
defer span.End()
defer runSpan.End()

// Increment the call depth which is restricted to 1024
in.evm.depth++
Expand Down Expand Up @@ -259,6 +262,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
res, err = operation.execute(&pc, in, callContext)

if err != nil {
runSpan.RecordError(err)
break
}
pc++
Expand Down

0 comments on commit 95523dd

Please sign in to comment.