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
16500702
Commit
16500702
authored
Sep 01, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track in flight games inside the scheduler component.
parent
07cf16db
Changes
4
Show 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 @
16500702
...
...
@@ -65,6 +65,7 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro
errs
=
append
(
errs
,
err
)
}
else
if
j
!=
nil
{
jobs
=
append
(
jobs
,
*
j
)
c
.
m
.
RecordGameUpdateScheduled
()
}
state
,
ok
:=
c
.
states
[
addr
]
if
ok
{
...
...
@@ -136,6 +137,7 @@ func (c *coordinator) processResult(j job) error {
state
.
inflight
=
false
state
.
status
=
j
.
status
c
.
deleteResolvedGameFiles
()
c
.
m
.
RecordGameUpdateCompleted
()
return
nil
}
...
...
op-challenger/game/scheduler/scheduler.go
View file @
16500702
...
...
@@ -13,6 +13,8 @@ var ErrBusy = errors.New("busy scheduling previous update")
type
SchedulerMetricer
interface
{
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGameUpdateScheduled
()
RecordGameUpdateCompleted
()
}
type
Scheduler
struct
{
...
...
op-challenger/metrics/metrics.go
View file @
16500702
...
...
@@ -26,6 +26,9 @@ type Metricer interface {
RecordCannonExecutionTime
(
t
float64
)
RecordGamesStatus
(
inProgress
,
defenderWon
,
challengerWon
int
)
RecordGameUpdateScheduled
()
RecordGameUpdateCompleted
()
}
type
Metrics
struct
{
...
...
@@ -44,6 +47,7 @@ type Metrics struct {
cannonExecutionTime
prometheus
.
Histogram
trackedGames
prometheus
.
GaugeVec
inflightGames
prometheus
.
Gauge
}
var
_
Metricer
=
(
*
Metrics
)(
nil
)
...
...
@@ -85,7 +89,9 @@ func NewMetrics() *Metrics {
Namespace
:
Namespace
,
Name
:
"cannon_execution_time"
,
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
{
Namespace
:
Namespace
,
...
...
@@ -94,6 +100,11 @@ func NewMetrics() *Metrics {
},
[]
string
{
"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 {
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
)
}
...
...
@@ -138,3 +154,11 @@ func (m *Metrics) RecordGamesStatus(inProgress, defenderWon, challengerWon int)
m
.
trackedGames
.
WithLabelValues
(
"defender_won"
)
.
Set
(
float64
(
defenderWon
))
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 @
16500702
...
...
@@ -19,3 +19,6 @@ func (*noopMetrics) RecordGameStep() {}
func
(
*
noopMetrics
)
RecordCannonExecutionTime
(
t
float64
)
{}
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