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
ea8c4628
Unverified
Commit
ea8c4628
authored
Dec 07, 2022
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-wheel: engine command logic
parent
c030d854
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
365 additions
and
0 deletions
+365
-0
engine.go
op-wheel/engine/engine.go
+278
-0
metrics.go
op-wheel/engine/metrics.go
+87
-0
No files found.
op-wheel/engine/engine.go
0 → 100644
View file @
ea8c4628
This diff is collapsed.
Click to expand it.
op-wheel/engine/metrics.go
0 → 100644
View file @
ea8c4628
package
engine
import
(
"encoding/binary"
"github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var
Namespace
=
"op_node"
type
Metricer
interface
{
RecordBlockFail
()
RecordBlockStats
(
hash
common
.
Hash
,
num
uint64
,
time
uint64
,
txs
uint64
,
gas
uint64
,
baseFee
float64
)
}
type
Metrics
struct
{
BlockFails
prometheus
.
Counter
BlockHash
prometheus
.
Gauge
BlockNum
prometheus
.
Gauge
BlockTime
prometheus
.
Gauge
BlockTxs
prometheus
.
Gauge
BlockGas
prometheus
.
Gauge
BlockBaseFee
prometheus
.
Gauge
}
func
NewMetrics
(
procName
string
,
registry
*
prometheus
.
Registry
)
*
Metrics
{
if
procName
==
""
{
procName
=
"default"
}
ns
:=
Namespace
+
"_"
+
procName
return
&
Metrics
{
BlockFails
:
promauto
.
With
(
registry
)
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Subsystem
:
"engine"
,
Name
:
"block_fails"
,
Help
:
"Total block building attempts that fail"
,
}),
BlockHash
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_hash"
,
Help
:
"current head block hash"
,
}),
BlockNum
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_num"
,
Help
:
"current head block number"
,
}),
BlockTime
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_time"
,
Help
:
"current head block time"
,
}),
BlockTxs
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_txs"
,
Help
:
"current head block txs"
,
}),
BlockGas
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_gas"
,
Help
:
"current head block gas"
,
}),
BlockBaseFee
:
promauto
.
With
(
registry
)
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"block_base_fee"
,
Help
:
"current head block basefee"
,
}),
}
}
func
(
r
*
Metrics
)
RecordBlockFail
()
{
r
.
BlockFails
.
Inc
()
}
func
(
r
*
Metrics
)
RecordBlockStats
(
hash
common
.
Hash
,
num
uint64
,
time
uint64
,
txs
uint64
,
gas
uint64
,
baseFee
float64
)
{
r
.
BlockHash
.
Set
(
float64
(
binary
.
LittleEndian
.
Uint64
(
hash
[
:
])))
// for pretty block-color changing charts
r
.
BlockNum
.
Set
(
float64
(
num
))
r
.
BlockTime
.
Set
(
float64
(
time
))
r
.
BlockTxs
.
Set
(
float64
(
txs
))
r
.
BlockGas
.
Set
(
float64
(
gas
))
r
.
BlockGas
.
Set
(
float64
(
baseFee
))
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
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