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
75a2d57b
Unverified
Commit
75a2d57b
authored
May 04, 2023
by
mergify[bot]
Committed by
GitHub
May 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into inphi/missing-batch
parents
96a92df3
11a204b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
51 deletions
+51
-51
metrics.go
op-batcher/metrics/metrics.go
+51
-51
No files found.
op-batcher/metrics/metrics.go
View file @
75a2d57b
...
@@ -49,25 +49,25 @@ type Metrics struct {
...
@@ -49,25 +49,25 @@ type Metrics struct {
opmetrics
.
RefMetrics
opmetrics
.
RefMetrics
txmetrics
.
TxMetrics
txmetrics
.
TxMetrics
I
nfo
prometheus
.
GaugeVec
i
nfo
prometheus
.
GaugeVec
U
p
prometheus
.
Gauge
u
p
prometheus
.
Gauge
// label by openend, closed, fully_submitted, timed_out
// label by openend, closed, fully_submitted, timed_out
C
hannelEvs
opmetrics
.
EventVec
c
hannelEvs
opmetrics
.
EventVec
P
endingBlocksCount
prometheus
.
GaugeVec
p
endingBlocksCount
prometheus
.
GaugeVec
B
locksAddedCount
prometheus
.
Gauge
b
locksAddedCount
prometheus
.
Gauge
C
hannelInputBytes
prometheus
.
GaugeVec
c
hannelInputBytes
prometheus
.
GaugeVec
C
hannelReadyBytes
prometheus
.
Gauge
c
hannelReadyBytes
prometheus
.
Gauge
C
hannelOutputBytes
prometheus
.
Gauge
c
hannelOutputBytes
prometheus
.
Gauge
C
hannelClosedReason
prometheus
.
Gauge
c
hannelClosedReason
prometheus
.
Gauge
C
hannelNumFrames
prometheus
.
Gauge
c
hannelNumFrames
prometheus
.
Gauge
C
hannelComprRatio
prometheus
.
Histogram
c
hannelComprRatio
prometheus
.
Histogram
C
hannelInputBytesTotal
prometheus
.
Counter
c
hannelInputBytesTotal
prometheus
.
Counter
C
hannelOutputBytesTotal
prometheus
.
Counter
c
hannelOutputBytesTotal
prometheus
.
Counter
B
atcherTxEvs
opmetrics
.
EventVec
b
atcherTxEvs
opmetrics
.
EventVec
}
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
var
_
Metricer
=
(
*
Metrics
)(
nil
)
...
@@ -89,75 +89,75 @@ func NewMetrics(procName string) *Metrics {
...
@@ -89,75 +89,75 @@ func NewMetrics(procName string) *Metrics {
RefMetrics
:
opmetrics
.
MakeRefMetrics
(
ns
,
factory
),
RefMetrics
:
opmetrics
.
MakeRefMetrics
(
ns
,
factory
),
TxMetrics
:
txmetrics
.
MakeTxMetrics
(
ns
,
factory
),
TxMetrics
:
txmetrics
.
MakeTxMetrics
(
ns
,
factory
),
I
nfo
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
i
nfo
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"info"
,
Name
:
"info"
,
Help
:
"Pseudo-metric tracking version and config info"
,
Help
:
"Pseudo-metric tracking version and config info"
,
},
[]
string
{
},
[]
string
{
"version"
,
"version"
,
}),
}),
U
p
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
u
p
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"up"
,
Name
:
"up"
,
Help
:
"1 if the op-batcher has finished starting up"
,
Help
:
"1 if the op-batcher has finished starting up"
,
}),
}),
C
hannelEvs
:
opmetrics
.
NewEventVec
(
factory
,
ns
,
""
,
"channel"
,
"Channel"
,
[]
string
{
"stage"
}),
c
hannelEvs
:
opmetrics
.
NewEventVec
(
factory
,
ns
,
""
,
"channel"
,
"Channel"
,
[]
string
{
"stage"
}),
P
endingBlocksCount
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
p
endingBlocksCount
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"pending_blocks_count"
,
Name
:
"pending_blocks_count"
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
},
[]
string
{
"stage"
}),
},
[]
string
{
"stage"
}),
B
locksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
b
locksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"blocks_added_count"
,
Name
:
"blocks_added_count"
,
Help
:
"Total number of blocks added to current channel."
,
Help
:
"Total number of blocks added to current channel."
,
}),
}),
C
hannelInputBytes
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
c
hannelInputBytes
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"input_bytes"
,
Name
:
"input_bytes"
,
Help
:
"Number of input bytes to a channel."
,
Help
:
"Number of input bytes to a channel."
,
},
[]
string
{
"stage"
}),
},
[]
string
{
"stage"
}),
C
hannelReadyBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelReadyBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"ready_bytes"
,
Name
:
"ready_bytes"
,
Help
:
"Number of bytes ready in the compression buffer."
,
Help
:
"Number of bytes ready in the compression buffer."
,
}),
}),
C
hannelOutputBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelOutputBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"output_bytes"
,
Name
:
"output_bytes"
,
Help
:
"Number of compressed output bytes from a channel."
,
Help
:
"Number of compressed output bytes from a channel."
,
}),
}),
C
hannelClosedReason
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelClosedReason
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"channel_closed_reason"
,
Name
:
"channel_closed_reason"
,
Help
:
"Pseudo-metric to record the reason a channel got closed."
,
Help
:
"Pseudo-metric to record the reason a channel got closed."
,
}),
}),
C
hannelNumFrames
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelNumFrames
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"channel_num_frames"
,
Name
:
"channel_num_frames"
,
Help
:
"Total number of frames of closed channel."
,
Help
:
"Total number of frames of closed channel."
,
}),
}),
C
hannelComprRatio
:
factory
.
NewHistogram
(
prometheus
.
HistogramOpts
{
c
hannelComprRatio
:
factory
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"channel_compr_ratio"
,
Name
:
"channel_compr_ratio"
,
Help
:
"Compression ratios of closed channel."
,
Help
:
"Compression ratios of closed channel."
,
Buckets
:
append
([]
float64
{
0.1
,
0.2
},
prometheus
.
LinearBuckets
(
0.3
,
0.05
,
14
)
...
),
Buckets
:
append
([]
float64
{
0.1
,
0.2
},
prometheus
.
LinearBuckets
(
0.3
,
0.05
,
14
)
...
),
}),
}),
C
hannelInputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
c
hannelInputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"input_bytes_total"
,
Name
:
"input_bytes_total"
,
Help
:
"Total number of bytes to a channel."
,
Help
:
"Total number of bytes to a channel."
,
}),
}),
C
hannelOutputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
c
hannelOutputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"output_bytes_total"
,
Name
:
"output_bytes_total"
,
Help
:
"Total number of compressed output bytes from a channel."
,
Help
:
"Total number of compressed output bytes from a channel."
,
}),
}),
B
atcherTxEvs
:
opmetrics
.
NewEventVec
(
factory
,
ns
,
""
,
"batcher_tx"
,
"BatcherTx"
,
[]
string
{
"stage"
}),
b
atcherTxEvs
:
opmetrics
.
NewEventVec
(
factory
,
ns
,
""
,
"batcher_tx"
,
"BatcherTx"
,
[]
string
{
"stage"
}),
}
}
}
}
...
@@ -177,13 +177,13 @@ func (m *Metrics) StartBalanceMetrics(ctx context.Context,
...
@@ -177,13 +177,13 @@ func (m *Metrics) StartBalanceMetrics(ctx context.Context,
// RecordInfo sets a pseudo-metric that contains versioning and
// RecordInfo sets a pseudo-metric that contains versioning and
// config info for the op-batcher.
// config info for the op-batcher.
func
(
m
*
Metrics
)
RecordInfo
(
version
string
)
{
func
(
m
*
Metrics
)
RecordInfo
(
version
string
)
{
m
.
I
nfo
.
WithLabelValues
(
version
)
.
Set
(
1
)
m
.
i
nfo
.
WithLabelValues
(
version
)
.
Set
(
1
)
}
}
// RecordUp sets the up metric to 1.
// RecordUp sets the up metric to 1.
func
(
m
*
Metrics
)
RecordUp
()
{
func
(
m
*
Metrics
)
RecordUp
()
{
prometheus
.
MustRegister
()
prometheus
.
MustRegister
()
m
.
U
p
.
Set
(
1
)
m
.
u
p
.
Set
(
1
)
}
}
const
(
const
(
...
@@ -210,37 +210,37 @@ func (m *Metrics) RecordL2BlocksLoaded(l2ref eth.L2BlockRef) {
...
@@ -210,37 +210,37 @@ func (m *Metrics) RecordL2BlocksLoaded(l2ref eth.L2BlockRef) {
}
}
func
(
m
*
Metrics
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
{
func
(
m
*
Metrics
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
{
m
.
C
hannelEvs
.
Record
(
StageOpened
)
m
.
c
hannelEvs
.
Record
(
StageOpened
)
m
.
B
locksAddedCount
.
Set
(
0
)
// reset
m
.
b
locksAddedCount
.
Set
(
0
)
// reset
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageOpened
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageOpened
)
.
Set
(
float64
(
numPendingBlocks
))
}
}
// RecordL2BlocksAdded should be called when L2 block were added to the channel
// RecordL2BlocksAdded should be called when L2 block were added to the channel
// builder, with the latest added block.
// builder, with the latest added block.
func
(
m
*
Metrics
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
{
func
(
m
*
Metrics
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
{
m
.
RecordL2Ref
(
StageAdded
,
l2ref
)
m
.
RecordL2Ref
(
StageAdded
,
l2ref
)
m
.
B
locksAddedCount
.
Add
(
float64
(
numBlocksAdded
))
m
.
b
locksAddedCount
.
Add
(
float64
(
numBlocksAdded
))
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
C
hannelInputBytes
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
inputBytes
))
m
.
c
hannelInputBytes
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
inputBytes
))
m
.
C
hannelReadyBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
c
hannelReadyBytes
.
Set
(
float64
(
outputComprBytes
))
}
}
func
(
m
*
Metrics
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
{
func
(
m
*
Metrics
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
{
m
.
C
hannelEvs
.
Record
(
StageClosed
)
m
.
c
hannelEvs
.
Record
(
StageClosed
)
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
C
hannelNumFrames
.
Set
(
float64
(
numFrames
))
m
.
c
hannelNumFrames
.
Set
(
float64
(
numFrames
))
m
.
C
hannelInputBytes
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
inputBytes
))
m
.
c
hannelInputBytes
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
inputBytes
))
m
.
C
hannelOutputBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
c
hannelOutputBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
C
hannelInputBytesTotal
.
Add
(
float64
(
inputBytes
))
m
.
c
hannelInputBytesTotal
.
Add
(
float64
(
inputBytes
))
m
.
C
hannelOutputBytesTotal
.
Add
(
float64
(
outputComprBytes
))
m
.
c
hannelOutputBytesTotal
.
Add
(
float64
(
outputComprBytes
))
var
comprRatio
float64
var
comprRatio
float64
if
inputBytes
>
0
{
if
inputBytes
>
0
{
comprRatio
=
float64
(
outputComprBytes
)
/
float64
(
inputBytes
)
comprRatio
=
float64
(
outputComprBytes
)
/
float64
(
inputBytes
)
}
}
m
.
C
hannelComprRatio
.
Observe
(
comprRatio
)
m
.
c
hannelComprRatio
.
Observe
(
comprRatio
)
m
.
C
hannelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
m
.
c
hannelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
}
}
func
ClosedReasonToNum
(
reason
error
)
int
{
func
ClosedReasonToNum
(
reason
error
)
int
{
...
@@ -249,21 +249,21 @@ func ClosedReasonToNum(reason error) int {
...
@@ -249,21 +249,21 @@ func ClosedReasonToNum(reason error) int {
}
}
func
(
m
*
Metrics
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
{
func
(
m
*
Metrics
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
{
m
.
C
hannelEvs
.
Record
(
StageFullySubmitted
)
m
.
c
hannelEvs
.
Record
(
StageFullySubmitted
)
}
}
func
(
m
*
Metrics
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
{
func
(
m
*
Metrics
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
{
m
.
C
hannelEvs
.
Record
(
StageTimedOut
)
m
.
c
hannelEvs
.
Record
(
StageTimedOut
)
}
}
func
(
m
*
Metrics
)
RecordBatchTxSubmitted
()
{
func
(
m
*
Metrics
)
RecordBatchTxSubmitted
()
{
m
.
B
atcherTxEvs
.
Record
(
TxStageSubmitted
)
m
.
b
atcherTxEvs
.
Record
(
TxStageSubmitted
)
}
}
func
(
m
*
Metrics
)
RecordBatchTxSuccess
()
{
func
(
m
*
Metrics
)
RecordBatchTxSuccess
()
{
m
.
B
atcherTxEvs
.
Record
(
TxStageSuccess
)
m
.
b
atcherTxEvs
.
Record
(
TxStageSuccess
)
}
}
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
m
.
B
atcherTxEvs
.
Record
(
TxStageFailed
)
m
.
b
atcherTxEvs
.
Record
(
TxStageFailed
)
}
}
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