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
a67902ca
Commit
a67902ca
authored
May 04, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the op-batcher metrics field to be unexported
parent
31967a73
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 @
a67902ca
...
...
@@ -49,25 +49,25 @@ type Metrics struct {
opmetrics
.
RefMetrics
txmetrics
.
TxMetrics
I
nfo
prometheus
.
GaugeVec
U
p
prometheus
.
Gauge
i
nfo
prometheus
.
GaugeVec
u
p
prometheus
.
Gauge
// label by openend, closed, fully_submitted, timed_out
C
hannelEvs
opmetrics
.
EventVec
c
hannelEvs
opmetrics
.
EventVec
P
endingBlocksCount
prometheus
.
GaugeVec
B
locksAddedCount
prometheus
.
Gauge
p
endingBlocksCount
prometheus
.
GaugeVec
b
locksAddedCount
prometheus
.
Gauge
C
hannelInputBytes
prometheus
.
GaugeVec
C
hannelReadyBytes
prometheus
.
Gauge
C
hannelOutputBytes
prometheus
.
Gauge
C
hannelClosedReason
prometheus
.
Gauge
C
hannelNumFrames
prometheus
.
Gauge
C
hannelComprRatio
prometheus
.
Histogram
C
hannelInputBytesTotal
prometheus
.
Counter
C
hannelOutputBytesTotal
prometheus
.
Counter
c
hannelInputBytes
prometheus
.
GaugeVec
c
hannelReadyBytes
prometheus
.
Gauge
c
hannelOutputBytes
prometheus
.
Gauge
c
hannelClosedReason
prometheus
.
Gauge
c
hannelNumFrames
prometheus
.
Gauge
c
hannelComprRatio
prometheus
.
Histogram
c
hannelInputBytesTotal
prometheus
.
Counter
c
hannelOutputBytesTotal
prometheus
.
Counter
B
atcherTxEvs
opmetrics
.
EventVec
b
atcherTxEvs
opmetrics
.
EventVec
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
...
...
@@ -89,75 +89,75 @@ func NewMetrics(procName string) *Metrics {
RefMetrics
:
opmetrics
.
MakeRefMetrics
(
ns
,
factory
),
TxMetrics
:
txmetrics
.
MakeTxMetrics
(
ns
,
factory
),
I
nfo
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
i
nfo
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"info"
,
Help
:
"Pseudo-metric tracking version and config info"
,
},
[]
string
{
"version"
,
}),
U
p
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
u
p
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"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
,
Name
:
"pending_blocks_count"
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
},
[]
string
{
"stage"
}),
B
locksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
b
locksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"blocks_added_count"
,
Help
:
"Total number of blocks added to current channel."
,
}),
C
hannelInputBytes
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
c
hannelInputBytes
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"input_bytes"
,
Help
:
"Number of input bytes to a channel."
,
},
[]
string
{
"stage"
}),
C
hannelReadyBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelReadyBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"ready_bytes"
,
Help
:
"Number of bytes ready in the compression buffer."
,
}),
C
hannelOutputBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelOutputBytes
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"output_bytes"
,
Help
:
"Number of compressed output bytes from a channel."
,
}),
C
hannelClosedReason
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
c
hannelClosedReason
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"channel_closed_reason"
,
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
,
Name
:
"channel_num_frames"
,
Help
:
"Total number of frames of closed channel."
,
}),
C
hannelComprRatio
:
factory
.
NewHistogram
(
prometheus
.
HistogramOpts
{
c
hannelComprRatio
:
factory
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Name
:
"channel_compr_ratio"
,
Help
:
"Compression ratios of closed channel."
,
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
,
Name
:
"input_bytes_total"
,
Help
:
"Total number of bytes to a channel."
,
}),
C
hannelOutputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
c
hannelOutputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Name
:
"output_bytes_total"
,
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,
// RecordInfo sets a pseudo-metric that contains versioning and
// config info for the op-batcher.
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.
func
(
m
*
Metrics
)
RecordUp
()
{
prometheus
.
MustRegister
()
m
.
U
p
.
Set
(
1
)
m
.
u
p
.
Set
(
1
)
}
const
(
...
...
@@ -210,37 +210,37 @@ func (m *Metrics) RecordL2BlocksLoaded(l2ref eth.L2BlockRef) {
}
func
(
m
*
Metrics
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
{
m
.
C
hannelEvs
.
Record
(
StageOpened
)
m
.
B
locksAddedCount
.
Set
(
0
)
// reset
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageOpened
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
c
hannelEvs
.
Record
(
StageOpened
)
m
.
b
locksAddedCount
.
Set
(
0
)
// reset
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageOpened
)
.
Set
(
float64
(
numPendingBlocks
))
}
// RecordL2BlocksAdded should be called when L2 block were added to the channel
// builder, with the latest added block.
func
(
m
*
Metrics
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
{
m
.
RecordL2Ref
(
StageAdded
,
l2ref
)
m
.
B
locksAddedCount
.
Add
(
float64
(
numBlocksAdded
))
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
C
hannelInputBytes
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
inputBytes
))
m
.
C
hannelReadyBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
b
locksAddedCount
.
Add
(
float64
(
numBlocksAdded
))
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
c
hannelInputBytes
.
WithLabelValues
(
StageAdded
)
.
Set
(
float64
(
inputBytes
))
m
.
c
hannelReadyBytes
.
Set
(
float64
(
outputComprBytes
))
}
func
(
m
*
Metrics
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
{
m
.
C
hannelEvs
.
Record
(
StageClosed
)
m
.
P
endingBlocksCount
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
C
hannelNumFrames
.
Set
(
float64
(
numFrames
))
m
.
C
hannelInputBytes
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
inputBytes
))
m
.
C
hannelOutputBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
C
hannelInputBytesTotal
.
Add
(
float64
(
inputBytes
))
m
.
C
hannelOutputBytesTotal
.
Add
(
float64
(
outputComprBytes
))
m
.
c
hannelEvs
.
Record
(
StageClosed
)
m
.
p
endingBlocksCount
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
numPendingBlocks
))
m
.
c
hannelNumFrames
.
Set
(
float64
(
numFrames
))
m
.
c
hannelInputBytes
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
inputBytes
))
m
.
c
hannelOutputBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
c
hannelInputBytesTotal
.
Add
(
float64
(
inputBytes
))
m
.
c
hannelOutputBytesTotal
.
Add
(
float64
(
outputComprBytes
))
var
comprRatio
float64
if
inputBytes
>
0
{
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
{
...
...
@@ -249,21 +249,21 @@ func ClosedReasonToNum(reason error) int {
}
func
(
m
*
Metrics
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
{
m
.
C
hannelEvs
.
Record
(
StageFullySubmitted
)
m
.
c
hannelEvs
.
Record
(
StageFullySubmitted
)
}
func
(
m
*
Metrics
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
{
m
.
C
hannelEvs
.
Record
(
StageTimedOut
)
m
.
c
hannelEvs
.
Record
(
StageTimedOut
)
}
func
(
m
*
Metrics
)
RecordBatchTxSubmitted
()
{
m
.
B
atcherTxEvs
.
Record
(
TxStageSubmitted
)
m
.
b
atcherTxEvs
.
Record
(
TxStageSubmitted
)
}
func
(
m
*
Metrics
)
RecordBatchTxSuccess
()
{
m
.
B
atcherTxEvs
.
Record
(
TxStageSuccess
)
m
.
b
atcherTxEvs
.
Record
(
TxStageSuccess
)
}
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