Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
b424c7c3
Unverified
Commit
b424c7c3
authored
Apr 04, 2023
by
OptimismBot
Committed by
GitHub
Apr 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5331 from shrimalmadhur/madhur/tx-metrics
txmgr: add more tx metrics
parents
44eec0de
0c3b866b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
noop.go
op-service/txmgr/metrics/noop.go
+3
-1
tx_metrics.go
op-service/txmgr/metrics/tx_metrics.go
+25
-1
txmgr.go
op-service/txmgr/txmgr.go
+5
-0
No files found.
op-service/txmgr/metrics/noop.go
View file @
b424c7c3
...
@@ -4,4 +4,6 @@ import "github.com/ethereum/go-ethereum/core/types"
...
@@ -4,4 +4,6 @@ import "github.com/ethereum/go-ethereum/core/types"
type
NoopTxMetrics
struct
{}
type
NoopTxMetrics
struct
{}
func
(
*
NoopTxMetrics
)
RecordL1GasFee
(
*
types
.
Receipt
)
{}
func
(
*
NoopTxMetrics
)
RecordL1GasFee
(
*
types
.
Receipt
)
{}
func
(
*
NoopTxMetrics
)
RecordGasBumpCount
(
int
)
{}
func
(
*
NoopTxMetrics
)
RecordTxConfirmationLatency
(
int64
)
{}
op-service/txmgr/metrics/tx_metrics.go
View file @
b424c7c3
...
@@ -10,10 +10,14 @@ import (
...
@@ -10,10 +10,14 @@ import (
type
TxMetricer
interface
{
type
TxMetricer
interface
{
RecordL1GasFee
(
receipt
*
types
.
Receipt
)
RecordL1GasFee
(
receipt
*
types
.
Receipt
)
RecordGasBumpCount
(
times
int
)
RecordTxConfirmationLatency
(
latency
int64
)
}
}
type
TxMetrics
struct
{
type
TxMetrics
struct
{
TxL1GasFee
prometheus
.
Gauge
TxL1GasFee
prometheus
.
Gauge
TxGasBump
prometheus
.
Gauge
LatencyConfirmedTx
prometheus
.
Gauge
}
}
var
_
TxMetricer
=
(
*
TxMetrics
)(
nil
)
var
_
TxMetricer
=
(
*
TxMetrics
)(
nil
)
...
@@ -26,9 +30,29 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
...
@@ -26,9 +30,29 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
Help
:
"L1 gas fee for transactions in GWEI"
,
Help
:
"L1 gas fee for transactions in GWEI"
,
Subsystem
:
"txmgr"
,
Subsystem
:
"txmgr"
,
}),
}),
TxGasBump
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"tx_gas_bump"
,
Help
:
"Number of times a transaction gas needed to be bumped before it got included"
,
Subsystem
:
"txmgr"
,
}),
LatencyConfirmedTx
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"tx_confirmed_latency_ms"
,
Help
:
"Latency of a confirmed transaction in milliseconds"
,
Subsystem
:
"txmgr"
,
}),
}
}
}
}
func
(
t
*
TxMetrics
)
RecordL1GasFee
(
receipt
*
types
.
Receipt
)
{
func
(
t
*
TxMetrics
)
RecordL1GasFee
(
receipt
*
types
.
Receipt
)
{
t
.
TxL1GasFee
.
Set
(
float64
(
receipt
.
EffectiveGasPrice
.
Uint64
()
*
receipt
.
GasUsed
/
params
.
GWei
))
t
.
TxL1GasFee
.
Set
(
float64
(
receipt
.
EffectiveGasPrice
.
Uint64
()
*
receipt
.
GasUsed
/
params
.
GWei
))
}
}
func
(
t
*
TxMetrics
)
RecordGasBumpCount
(
times
int
)
{
t
.
TxGasBump
.
Set
(
float64
(
times
))
}
func
(
t
*
TxMetrics
)
RecordTxConfirmationLatency
(
latency
int64
)
{
t
.
LatencyConfirmedTx
.
Set
(
float64
(
latency
))
}
op-service/txmgr/txmgr.go
View file @
b424c7c3
...
@@ -216,6 +216,7 @@ func (m *SimpleTxManager) send(ctx context.Context, tx *types.Transaction) (*typ
...
@@ -216,6 +216,7 @@ func (m *SimpleTxManager) send(ctx context.Context, tx *types.Transaction) (*typ
ticker
:=
time
.
NewTicker
(
m
.
cfg
.
ResubmissionTimeout
)
ticker
:=
time
.
NewTicker
(
m
.
cfg
.
ResubmissionTimeout
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
bumpCounter
:=
0
for
{
for
{
select
{
select
{
case
<-
ticker
.
C
:
case
<-
ticker
.
C
:
...
@@ -231,12 +232,14 @@ func (m *SimpleTxManager) send(ctx context.Context, tx *types.Transaction) (*typ
...
@@ -231,12 +232,14 @@ func (m *SimpleTxManager) send(ctx context.Context, tx *types.Transaction) (*typ
// Increase the gas price & submit the new transaction
// Increase the gas price & submit the new transaction
tx
=
m
.
increaseGasPrice
(
ctx
,
tx
)
tx
=
m
.
increaseGasPrice
(
ctx
,
tx
)
wg
.
Add
(
1
)
wg
.
Add
(
1
)
bumpCounter
+=
1
go
sendTxAsync
(
tx
)
go
sendTxAsync
(
tx
)
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
return
nil
,
ctx
.
Err
()
case
receipt
:=
<-
receiptChan
:
case
receipt
:=
<-
receiptChan
:
m
.
metr
.
RecordGasBumpCount
(
bumpCounter
)
return
receipt
,
nil
return
receipt
,
nil
}
}
}
}
...
@@ -251,6 +254,7 @@ func (m *SimpleTxManager) publishAndWaitForTx(ctx context.Context, tx *types.Tra
...
@@ -251,6 +254,7 @@ func (m *SimpleTxManager) publishAndWaitForTx(ctx context.Context, tx *types.Tra
cCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
m
.
cfg
.
NetworkTimeout
)
cCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
m
.
cfg
.
NetworkTimeout
)
defer
cancel
()
defer
cancel
()
t
:=
time
.
Now
()
err
:=
m
.
backend
.
SendTransaction
(
cCtx
,
tx
)
err
:=
m
.
backend
.
SendTransaction
(
cCtx
,
tx
)
sendState
.
ProcessSendError
(
err
)
sendState
.
ProcessSendError
(
err
)
...
@@ -282,6 +286,7 @@ func (m *SimpleTxManager) publishAndWaitForTx(ctx context.Context, tx *types.Tra
...
@@ -282,6 +286,7 @@ func (m *SimpleTxManager) publishAndWaitForTx(ctx context.Context, tx *types.Tra
}
}
select
{
select
{
case
receiptChan
<-
receipt
:
case
receiptChan
<-
receipt
:
m
.
metr
.
RecordTxConfirmationLatency
(
time
.
Since
(
t
)
.
Milliseconds
())
m
.
metr
.
RecordL1GasFee
(
receipt
)
m
.
metr
.
RecordL1GasFee
(
receipt
)
default
:
default
:
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment