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
9f926a60
Unverified
Commit
9f926a60
authored
Sep 05, 2023
by
OptimismBot
Committed by
GitHub
Sep 05, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7086 from ethereum-optimism/refcell/inflight-gauge
feat(op-challenger): Inflight game metrics
parents
23d0635b
bfa2f7ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
3 deletions
+34
-3
coordinator.go
op-challenger/game/scheduler/coordinator.go
+2
-0
scheduler.go
op-challenger/game/scheduler/scheduler.go
+2
-0
metrics.go
op-challenger/metrics/metrics.go
+27
-3
noop.go
op-challenger/metrics/noop.go
+3
-0
No files found.
op-challenger/game/scheduler/coordinator.go
View file @
9f926a60
...
@@ -65,6 +65,7 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro
...
@@ -65,6 +65,7 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro
errs
=
append
(
errs
,
err
)
errs
=
append
(
errs
,
err
)
}
else
if
j
!=
nil
{
}
else
if
j
!=
nil
{
jobs
=
append
(
jobs
,
*
j
)
jobs
=
append
(
jobs
,
*
j
)
c
.
m
.
RecordGameUpdateScheduled
()
}
}
state
,
ok
:=
c
.
states
[
addr
]
state
,
ok
:=
c
.
states
[
addr
]
if
ok
{
if
ok
{
...
@@ -136,6 +137,7 @@ func (c *coordinator) processResult(j job) error {
...
@@ -136,6 +137,7 @@ func (c *coordinator) processResult(j job) error {
state
.
inflight
=
false
state
.
inflight
=
false
state
.
status
=
j
.
status
state
.
status
=
j
.
status
c
.
deleteResolvedGameFiles
()
c
.
deleteResolvedGameFiles
()
c
.
m
.
RecordGameUpdateCompleted
()
return
nil
return
nil
}
}
...
...
op-challenger/game/scheduler/scheduler.go
View file @
9f926a60
...
@@ -13,6 +13,8 @@ var ErrBusy = errors.New("busy scheduling previous update")
...
@@ -13,6 +13,8 @@ var ErrBusy = errors.New("busy scheduling previous update")
type
SchedulerMetricer
interface
{
type
SchedulerMetricer
interface
{
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGameUpdateScheduled
()
RecordGameUpdateCompleted
()
}
}
type
Scheduler
struct
{
type
Scheduler
struct
{
...
...
op-challenger/metrics/metrics.go
View file @
9f926a60
...
@@ -26,6 +26,9 @@ type Metricer interface {
...
@@ -26,6 +26,9 @@ type Metricer interface {
RecordCannonExecutionTime
(
t
float64
)
RecordCannonExecutionTime
(
t
float64
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGameUpdateScheduled
()
RecordGameUpdateCompleted
()
}
}
type
Metrics
struct
{
type
Metrics
struct
{
...
@@ -43,7 +46,8 @@ type Metrics struct {
...
@@ -43,7 +46,8 @@ type Metrics struct {
cannonExecutionTime
prometheus
.
Histogram
cannonExecutionTime
prometheus
.
Histogram
trackedGames
prometheus
.
GaugeVec
trackedGames
prometheus
.
GaugeVec
inflightGames
prometheus
.
Gauge
}
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
var
_
Metricer
=
(
*
Metrics
)(
nil
)
...
@@ -85,7 +89,9 @@ func NewMetrics() *Metrics {
...
@@ -85,7 +89,9 @@ func NewMetrics() *Metrics {
Namespace
:
Namespace
,
Namespace
:
Namespace
,
Name
:
"cannon_execution_time"
,
Name
:
"cannon_execution_time"
,
Help
:
"Time (in seconds) to execute cannon"
,
Help
:
"Time (in seconds) to execute cannon"
,
Buckets
:
append
([]
float64
{
1.0
,
10.0
},
prometheus
.
ExponentialBuckets
(
30.0
,
2.0
,
14
)
...
),
Buckets
:
append
(
[]
float64
{
1.0
,
10.0
},
prometheus
.
ExponentialBuckets
(
30.0
,
2.0
,
14
)
...
),
}),
}),
trackedGames
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
trackedGames
:
*
factory
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
Namespace
,
Namespace
:
Namespace
,
...
@@ -94,6 +100,11 @@ func NewMetrics() *Metrics {
...
@@ -94,6 +100,11 @@ func NewMetrics() *Metrics {
},
[]
string
{
},
[]
string
{
"status"
,
"status"
,
}),
}),
inflightGames
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
Namespace
,
Name
:
"inflight_games"
,
Help
:
"Number of games being tracked by the challenger"
,
}),
}
}
}
}
...
@@ -101,7 +112,12 @@ func (m *Metrics) Serve(ctx context.Context, host string, port int) error {
...
@@ -101,7 +112,12 @@ func (m *Metrics) Serve(ctx context.Context, host string, port int) error {
return
opmetrics
.
ListenAndServe
(
ctx
,
m
.
registry
,
host
,
port
)
return
opmetrics
.
ListenAndServe
(
ctx
,
m
.
registry
,
host
,
port
)
}
}
func
(
m
*
Metrics
)
StartBalanceMetrics
(
ctx
context
.
Context
,
l
log
.
Logger
,
client
*
ethclient
.
Client
,
account
common
.
Address
)
{
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
)
opmetrics
.
LaunchBalanceMetrics
(
ctx
,
l
,
m
.
registry
,
m
.
ns
,
client
,
account
)
}
}
...
@@ -138,3 +154,11 @@ func (m *Metrics) RecordGamesStatus(inProgress, defenderWon, challengerWon int)
...
@@ -138,3 +154,11 @@ func (m *Metrics) RecordGamesStatus(inProgress, defenderWon, challengerWon int)
m
.
trackedGames
.
WithLabelValues
(
"defender_won"
)
.
Set
(
float64
(
defenderWon
))
m
.
trackedGames
.
WithLabelValues
(
"defender_won"
)
.
Set
(
float64
(
defenderWon
))
m
.
trackedGames
.
WithLabelValues
(
"challenger_won"
)
.
Set
(
float64
(
challengerWon
))
m
.
trackedGames
.
WithLabelValues
(
"challenger_won"
)
.
Set
(
float64
(
challengerWon
))
}
}
func
(
m
*
Metrics
)
RecordGameUpdateScheduled
()
{
m
.
inflightGames
.
Add
(
1
)
}
func
(
m
*
Metrics
)
RecordGameUpdateCompleted
()
{
m
.
inflightGames
.
Sub
(
1
)
}
op-challenger/metrics/noop.go
View file @
9f926a60
...
@@ -19,3 +19,6 @@ func (*noopMetrics) RecordGameStep() {}
...
@@ -19,3 +19,6 @@ func (*noopMetrics) RecordGameStep() {}
func
(
*
noopMetrics
)
RecordCannonExecutionTime
(
t
float64
)
{}
func
(
*
noopMetrics
)
RecordCannonExecutionTime
(
t
float64
)
{}
func
(
*
noopMetrics
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
{}
func
(
*
noopMetrics
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
{}
func
(
*
noopMetrics
)
RecordGameUpdateScheduled
()
{}
func
(
*
noopMetrics
)
RecordGameUpdateCompleted
()
{}
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