Skip to content

Commit

Permalink
Fix/simplify value store span attribute setup
Browse files Browse the repository at this point in the history
This bug has been here for a while, prior to the environment refactoring.
The extra negation on IsSample check meant that we were setting up span
attribute on only non-sampled transactions.  Nothing got logged.
  • Loading branch information
pattyshack committed Dec 19, 2022
1 parent 5b2986f commit 95e3e98
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions fvm/environment/value_store.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package environment

import (
"encoding/hex"
"fmt"

"github.com/onflow/atree"
"go.opentelemetry.io/otel/attribute"

"github.com/onflow/flow-go/fvm/errors"
"github.com/onflow/flow-go/fvm/state"
Expand Down Expand Up @@ -122,16 +120,7 @@ func (store *valueStore) GetValue(

var valueByteSize int
span := store.tracer.StartSpanFromRoot(trace.FVMEnvGetValue)
defer func() {
if !trace.IsSampled(span) {
span.SetAttributes(
attribute.String("owner", hex.EncodeToString(owner)),
attribute.String("key", key),
attribute.Int("valueByteSize", valueByteSize),
)
}
span.End()
}()
defer span.End()

address := flow.BytesToAddress(owner)
if state.IsFVMStateKey(string(owner), key) {
Expand Down Expand Up @@ -162,12 +151,6 @@ func (store *valueStore) SetValue(
key := string(keyBytes)

span := store.tracer.StartSpanFromRoot(trace.FVMEnvSetValue)
if !trace.IsSampled(span) {
span.SetAttributes(
attribute.String("owner", hex.EncodeToString(owner)),
attribute.String("key", key),
)
}
defer span.End()

address := flow.BytesToAddress(owner)
Expand Down

0 comments on commit 95e3e98

Please sign in to comment.