feat: missing messags in the last hour (#12)
This commit is contained in:
parent
31ef4403f0
commit
c69dea6da6
|
@ -214,7 +214,7 @@ func Execute(ctx context.Context, options Options) error {
|
|||
|
||||
runIdLogger.Info("missing messages recheck complete")
|
||||
|
||||
syncCheckTimer.Reset(30 * time.Minute)
|
||||
syncCheckTimer.Reset(15 * time.Minute)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
@ -442,12 +442,22 @@ func (app *Application) checkMissingMessageStatus(ctx context.Context, storenode
|
|||
}
|
||||
|
||||
func (app *Application) countMissingMessages(storenodes []peer.ID) error {
|
||||
now := app.node.Timesource().Now().Add(-delay)
|
||||
|
||||
// Count messages in last hour (not including last 5 minutes)
|
||||
results, err := app.db.CountMissingMessages(now.Add(-time.Hour), now)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for storenode, cnt := range results {
|
||||
app.metrics.RecordMissingMessagesLastHour(storenode, cnt)
|
||||
}
|
||||
|
||||
// not including last two hours in now to let sync work
|
||||
now := app.node.Timesource().Now().Add(-2 * time.Hour)
|
||||
_2hAgo := now.Add(-2 * time.Hour)
|
||||
|
||||
// Count messages in last day (not including last two hours)
|
||||
results, err := app.db.CountMissingMessages(now.Add(-24*time.Hour), now)
|
||||
results, err = app.db.CountMissingMessages(now.Add(-24*time.Hour), _2hAgo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -456,7 +466,7 @@ func (app *Application) countMissingMessages(storenodes []peer.ID) error {
|
|||
}
|
||||
|
||||
// Count messages in last week (not including last two hours)
|
||||
results, err = app.db.CountMissingMessages(now.Add(-24*time.Hour*7), now)
|
||||
results, err = app.db.CountMissingMessages(_2hAgo.Add(-24*time.Hour*7), _2hAgo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -41,6 +41,14 @@ var topicLastSync = prometheus.NewGaugeVec(
|
|||
[]string{"fleetName", "pubsubtopic"},
|
||||
)
|
||||
|
||||
var missingMessagesLastHour = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "msgcounter_missing_messages_last_hour",
|
||||
Help: "The number of messages missing in last hour (excluding the last 5 minutes)",
|
||||
},
|
||||
[]string{"fleetName", "storenode"},
|
||||
)
|
||||
|
||||
var missingMessagesLastDay = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "msgcounter_missing_messages_last_day",
|
||||
|
@ -81,6 +89,7 @@ type Metrics interface {
|
|||
RecordStorenodeAvailability(peerID peer.ID, available bool)
|
||||
RecordTotalMissingMessages(cnt int)
|
||||
RecordLastSyncDate(topic string, date time.Time)
|
||||
RecordMissingMessagesLastHour(peerID peer.ID, cnt int)
|
||||
RecordMissingMessagesLastDay(peerID peer.ID, cnt int)
|
||||
RecordMissingMessagesLastWeek(peerID peer.ID, cnt int)
|
||||
RecordMissingMessagesPrevHour(peerID peer.ID, cnt int)
|
||||
|
@ -131,6 +140,12 @@ func (m *metricsImpl) RecordLastSyncDate(topic string, date time.Time) {
|
|||
}()
|
||||
}
|
||||
|
||||
func (m *metricsImpl) RecordMissingMessagesLastHour(peerID peer.ID, cnt int) {
|
||||
go func() {
|
||||
missingMessagesLastHour.WithLabelValues(m.fleetName, peerID.String()).Set(float64(cnt))
|
||||
}()
|
||||
}
|
||||
|
||||
func (m *metricsImpl) RecordMissingMessagesLastDay(peerID peer.ID, cnt int) {
|
||||
go func() {
|
||||
missingMessagesLastDay.WithLabelValues(m.fleetName, peerID.String()).Set(float64(cnt))
|
||||
|
|
Loading…
Reference in New Issue