File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package evmcore
1818
1919import (
2020 "errors"
21+ "github.com/Fantom-foundation/go-opera/tracing"
2122 "math"
2223 "math/big"
2324 "math/rand"
@@ -1828,6 +1829,8 @@ func (t *txLookup) Remove(hash common.Hash) {
18281829 t .lock .Lock ()
18291830 defer t .lock .Unlock ()
18301831
1832+ defer tracing .FinishTx (hash , "txLookup.Remove()" )
1833+
18311834 tx , ok := t .locals [hash ]
18321835 if ! ok {
18331836 tx , ok = t .remotes [hash ]
Original file line number Diff line number Diff line change @@ -2,14 +2,21 @@ package tracing
22
33import (
44 "sync"
5+ "time"
56
67 "github.com/ethereum/go-ethereum/common"
78 "github.com/opentracing/opentracing-go"
89)
910
11+ // txSpan wraps opentracing span and stores additional payload
12+ type txSpan struct {
13+ opentracing.Span
14+ begin time.Time
15+ }
16+
1017var (
1118 enabled bool
12- txSpans = make (map [common.Hash ]opentracing. Span )
19+ txSpans = make (map [common.Hash ]txSpan )
1320 txSpansMu sync.RWMutex
1421
1522 noopSpan = opentracing.NoopTracer {}.StartSpan ("" )
@@ -35,9 +42,13 @@ func StartTx(tx common.Hash, operation string) {
3542 return
3643 }
3744
38- span := opentracing .StartSpan ("lifecycle" )
45+ span := txSpan {
46+ Span : opentracing .StartSpan ("lifecycle" ),
47+ begin : time .Now (),
48+ }
3949 span .SetTag ("txhash" , tx .String ())
4050 span .SetTag ("enter" , operation )
51+
4152 txSpans [tx ] = span
4253}
4354
@@ -55,7 +66,9 @@ func FinishTx(tx common.Hash, operation string) {
5566 }
5667
5768 span .SetTag ("exit" , operation )
69+ span .SetTag ("time.millis" , time .Since (span .begin ).Milliseconds ())
5870 span .Finish ()
71+
5972 delete (txSpans , tx )
6073}
6174
You can’t perform that action at this time.
0 commit comments