Commit b0fd48c9 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-dispute-mon: Publish latest valid and invalid proposal times (#10564)

Changes latest_invalid_proposal metric to latest_proposal with a root_agreement label. Will enable alerting if the proposer isn't creating games on the expected schedule.
parent 38cd9944
...@@ -126,7 +126,7 @@ type Metricer interface { ...@@ -126,7 +126,7 @@ type Metricer interface {
RecordGameAgreement(status GameAgreementStatus, count int) RecordGameAgreement(status GameAgreementStatus, count int)
RecordLatestInvalidProposal(timestamp uint64) RecordLatestProposals(latestValid, latestInvalid uint64)
RecordIgnoredGames(count int) RecordIgnoredGames(count int)
...@@ -167,11 +167,11 @@ type Metrics struct { ...@@ -167,11 +167,11 @@ type Metrics struct {
lastOutputFetch prometheus.Gauge lastOutputFetch prometheus.Gauge
gamesAgreement prometheus.GaugeVec gamesAgreement prometheus.GaugeVec
latestInvalidProposal prometheus.Gauge latestProposals prometheus.GaugeVec
ignoredGames prometheus.Gauge ignoredGames prometheus.Gauge
failedGames prometheus.Gauge failedGames prometheus.Gauge
l2Challenges prometheus.GaugeVec l2Challenges prometheus.GaugeVec
requiredCollateral prometheus.GaugeVec requiredCollateral prometheus.GaugeVec
availableCollateral prometheus.GaugeVec availableCollateral prometheus.GaugeVec
...@@ -277,11 +277,12 @@ func NewMetrics() *Metrics { ...@@ -277,11 +277,12 @@ func NewMetrics() *Metrics {
"result_correctness", "result_correctness",
"root_agreement", "root_agreement",
}), }),
latestInvalidProposal: factory.NewGauge(prometheus.GaugeOpts{ latestProposals: *factory.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace, Namespace: Namespace,
Name: "latest_invalid_proposal", Name: "latest_proposal",
Help: "Timestamp of the most recent game with an invalid root claim in unix seconds", Help: "Timestamp of the most recent game with a valid or invalid root claim in unix seconds",
}), },
[]string{"root_agreement"}),
ignoredGames: factory.NewGauge(prometheus.GaugeOpts{ ignoredGames: factory.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace, Namespace: Namespace,
Name: "ignored_games", Name: "ignored_games",
...@@ -452,8 +453,9 @@ func (m *Metrics) RecordGameAgreement(status GameAgreementStatus, count int) { ...@@ -452,8 +453,9 @@ func (m *Metrics) RecordGameAgreement(status GameAgreementStatus, count int) {
m.gamesAgreement.WithLabelValues(labelValuesFor(status)...).Set(float64(count)) m.gamesAgreement.WithLabelValues(labelValuesFor(status)...).Set(float64(count))
} }
func (m *Metrics) RecordLatestInvalidProposal(timestamp uint64) { func (m *Metrics) RecordLatestProposals(latestValid, latestInvalid uint64) {
m.latestInvalidProposal.Set(float64(timestamp)) m.latestProposals.WithLabelValues("agree").Set(float64(latestValid))
m.latestProposals.WithLabelValues("disagree").Set(float64(latestInvalid))
} }
func (m *Metrics) RecordIgnoredGames(count int) { func (m *Metrics) RecordIgnoredGames(count int) {
......
...@@ -36,7 +36,7 @@ func (*NoopMetricsImpl) RecordOutputFetchTime(_ float64) {} ...@@ -36,7 +36,7 @@ func (*NoopMetricsImpl) RecordOutputFetchTime(_ float64) {}
func (*NoopMetricsImpl) RecordGameAgreement(_ GameAgreementStatus, _ int) {} func (*NoopMetricsImpl) RecordGameAgreement(_ GameAgreementStatus, _ int) {}
func (*NoopMetricsImpl) RecordLatestInvalidProposal(_ uint64) {} func (*NoopMetricsImpl) RecordLatestProposals(_ uint64, _ uint64) {}
func (*NoopMetricsImpl) RecordIgnoredGames(_ int) {} func (*NoopMetricsImpl) RecordIgnoredGames(_ int) {}
......
...@@ -16,7 +16,7 @@ var ( ...@@ -16,7 +16,7 @@ var (
type ForecastMetrics interface { type ForecastMetrics interface {
RecordGameAgreement(status metrics.GameAgreementStatus, count int) RecordGameAgreement(status metrics.GameAgreementStatus, count int)
RecordLatestInvalidProposal(timestamp uint64) RecordLatestProposals(validTimestamp, invalidTimestamp uint64)
RecordIgnoredGames(count int) RecordIgnoredGames(count int)
RecordFailedGames(count int) RecordFailedGames(count int)
} }
...@@ -33,6 +33,7 @@ type forecastBatch struct { ...@@ -33,6 +33,7 @@ type forecastBatch struct {
DisagreeChallengerWins int DisagreeChallengerWins int
LatestInvalidProposal uint64 LatestInvalidProposal uint64
LatestValidProposal uint64
} }
type Forecast struct { type Forecast struct {
...@@ -68,7 +69,7 @@ func (f *Forecast) recordBatch(batch forecastBatch, ignoredCount, failedCount in ...@@ -68,7 +69,7 @@ func (f *Forecast) recordBatch(batch forecastBatch, ignoredCount, failedCount in
f.metrics.RecordGameAgreement(metrics.AgreeDefenderAhead, batch.AgreeDefenderAhead) f.metrics.RecordGameAgreement(metrics.AgreeDefenderAhead, batch.AgreeDefenderAhead)
f.metrics.RecordGameAgreement(metrics.DisagreeDefenderAhead, batch.DisagreeDefenderAhead) f.metrics.RecordGameAgreement(metrics.DisagreeDefenderAhead, batch.DisagreeDefenderAhead)
f.metrics.RecordLatestInvalidProposal(batch.LatestInvalidProposal) f.metrics.RecordLatestProposals(batch.LatestValidProposal, batch.LatestInvalidProposal)
f.metrics.RecordIgnoredGames(ignoredCount) f.metrics.RecordIgnoredGames(ignoredCount)
f.metrics.RecordFailedGames(failedCount) f.metrics.RecordFailedGames(failedCount)
...@@ -85,6 +86,10 @@ func (f *Forecast) forecastGame(game *monTypes.EnrichedGameData, metrics *foreca ...@@ -85,6 +86,10 @@ func (f *Forecast) forecastGame(game *monTypes.EnrichedGameData, metrics *foreca
if metrics.LatestInvalidProposal < game.Timestamp { if metrics.LatestInvalidProposal < game.Timestamp {
metrics.LatestInvalidProposal = game.Timestamp metrics.LatestInvalidProposal = game.Timestamp
} }
} else {
if metrics.LatestValidProposal < game.Timestamp {
metrics.LatestValidProposal = game.Timestamp
}
} }
if game.Status != types.GameStatusInProgress { if game.Status != types.GameStatusInProgress {
......
...@@ -263,8 +263,8 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) { ...@@ -263,8 +263,8 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
{}, {},
mockRootClaim, mockRootClaim,
{}, {},
{}, // Expected latest invalid proposal (will have timestamp 7) {}, // Expected latest invalid proposal (will have timestamp 7)
mockRootClaim, mockRootClaim, // Expected latest valid proposal (will have timestamp 8)
} }
games := make([]*monTypes.EnrichedGameData, 9) games := make([]*monTypes.EnrichedGameData, 9)
for i := range games { for i := range games {
...@@ -293,6 +293,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) { ...@@ -293,6 +293,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
require.Equal(t, 3, m.ignoredGames) require.Equal(t, 3, m.ignoredGames)
require.Equal(t, 4, m.contractCreationFails) require.Equal(t, 4, m.contractCreationFails)
require.EqualValues(t, 7, m.latestInvalidProposal) require.EqualValues(t, 7, m.latestInvalidProposal)
require.EqualValues(t, 8, m.latestValidProposal)
} }
func setupForecastTest(t *testing.T) (*Forecast, *mockForecastMetrics, *testlog.CapturingHandler) { func setupForecastTest(t *testing.T) (*Forecast, *mockForecastMetrics, *testlog.CapturingHandler) {
...@@ -320,6 +321,7 @@ type mockForecastMetrics struct { ...@@ -320,6 +321,7 @@ type mockForecastMetrics struct {
gameAgreement map[metrics.GameAgreementStatus]int gameAgreement map[metrics.GameAgreementStatus]int
ignoredGames int ignoredGames int
latestInvalidProposal uint64 latestInvalidProposal uint64
latestValidProposal uint64
contractCreationFails int contractCreationFails int
} }
...@@ -331,8 +333,9 @@ func (m *mockForecastMetrics) RecordGameAgreement(status metrics.GameAgreementSt ...@@ -331,8 +333,9 @@ func (m *mockForecastMetrics) RecordGameAgreement(status metrics.GameAgreementSt
m.gameAgreement[status] = count m.gameAgreement[status] = count
} }
func (m *mockForecastMetrics) RecordLatestInvalidProposal(timestamp uint64) { func (m *mockForecastMetrics) RecordLatestProposals(valid, invalid uint64) {
m.latestInvalidProposal = timestamp m.latestValidProposal = valid
m.latestInvalidProposal = invalid
} }
func (m *mockForecastMetrics) RecordIgnoredGames(count int) { func (m *mockForecastMetrics) RecordIgnoredGames(count int) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment