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
85c16374
Unverified
Commit
85c16374
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 fix/proposer/metrics
parents
c7b4ac19
31967a73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
0 deletions
+145
-0
metrics.go
op-challenger/metrics/metrics.go
+124
-0
noop.go
op-challenger/metrics/noop.go
+21
-0
No files found.
op-challenger/metrics/metrics.go
0 → 100644
View file @
85c16374
package
metrics
import
(
"context"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
)
const
Namespace
=
"op_challenger"
type
Metricer
interface
{
RecordInfo
(
version
string
)
RecordUp
()
// Records all L1 and L2 block events
opmetrics
.
RefMetricer
// Record Tx metrics
txmetrics
.
TxMetricer
RecordValidOutput
(
l2ref
eth
.
L2BlockRef
)
RecordInvalidOutput
(
l2ref
eth
.
L2BlockRef
)
RecordOutputChallenged
(
l2ref
eth
.
L2BlockRef
)
}
type
Metrics
struct
{
ns
string
registry
*
prometheus
.
Registry
factory
opmetrics
.
Factory
opmetrics
.
RefMetrics
txmetrics
.
TxMetrics
info
prometheus
.
GaugeVec
up
prometheus
.
Gauge
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
func
NewMetrics
(
procName
string
)
*
Metrics
{
if
procName
==
""
{
procName
=
"default"
}
ns
:=
Namespace
+
"_"
+
procName
registry
:=
opmetrics
.
NewRegistry
()
factory
:=
opmetrics
.
With
(
registry
)
return
&
Metrics
{
ns
:
ns
,
registry
:
registry
,
factory
:
factory
,
RefMetrics
:
opmetrics
.
MakeRefMetrics
(
ns
,
factory
),
TxMetrics
:
txmetrics
.
MakeTxMetrics
(
ns
,
factory
),
info
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"info"
,
Help
:
"Pseudo-metric tracking version and config info"
,
},
[]
string
{
"version"
,
}),
up
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"up"
,
Help
:
"1 if the op-proposer has finished starting up"
,
}),
}
}
func
(
m
*
Metrics
)
Serve
(
ctx
context
.
Context
,
host
string
,
port
int
)
error
{
return
opmetrics
.
ListenAndServe
(
ctx
,
m
.
registry
,
host
,
port
)
}
func
(
m
*
Metrics
)
StartBalanceMetrics
(
ctx
context
.
Context
,
l
log
.
Logger
,
client
*
ethclient
.
Client
,
account
common
.
Address
)
{
opmetrics
.
LaunchBalanceMetrics
(
ctx
,
l
,
m
.
registry
,
m
.
ns
,
client
,
account
)
}
// RecordInfo sets a pseudo-metric that contains versioning and
// config info for the op-proposer.
func
(
m
*
Metrics
)
RecordInfo
(
version
string
)
{
m
.
info
.
WithLabelValues
(
version
)
.
Set
(
1
)
}
// RecordUp sets the up metric to 1.
func
(
m
*
Metrics
)
RecordUp
()
{
prometheus
.
MustRegister
()
m
.
up
.
Set
(
1
)
}
const
(
ValidOutput
=
"valid_output"
InvalidOutput
=
"invalid_output"
OutputChallenged
=
"output_challenged"
)
// RecordValidOutput should be called when a valid output is found
func
(
m
*
Metrics
)
RecordValidOutput
(
l2ref
eth
.
L2BlockRef
)
{
m
.
RecordL2Ref
(
ValidOutput
,
l2ref
)
}
// RecordInvalidOutput should be called when an invalid output is found
func
(
m
*
Metrics
)
RecordInvalidOutput
(
l2ref
eth
.
L2BlockRef
)
{
m
.
RecordL2Ref
(
InvalidOutput
,
l2ref
)
}
// RecordOutputChallenged should be called when an output is challenged
func
(
m
*
Metrics
)
RecordOutputChallenged
(
l2ref
eth
.
L2BlockRef
)
{
m
.
RecordL2Ref
(
OutputChallenged
,
l2ref
)
}
func
(
m
*
Metrics
)
Document
()
[]
opmetrics
.
DocumentedMetric
{
return
m
.
factory
.
Document
()
}
op-challenger/metrics/noop.go
0 → 100644
View file @
85c16374
package
metrics
import
(
"github.com/ethereum-optimism/optimism/op-node/eth"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
)
type
noopMetrics
struct
{
opmetrics
.
NoopRefMetrics
txmetrics
.
NoopTxMetrics
}
var
NoopMetrics
Metricer
=
new
(
noopMetrics
)
func
(
*
noopMetrics
)
RecordInfo
(
version
string
)
{}
func
(
*
noopMetrics
)
RecordUp
()
{}
func
(
*
noopMetrics
)
RecordValidOutput
(
l2ref
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordInvalidOutput
(
l2ref
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordOutputChallenged
(
l2ref
eth
.
L2BlockRef
)
{}
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