Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GROW-1241-health-command-single-provider-arg #1475

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
13 changes: 11 additions & 2 deletions protocol/monitoring/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,19 @@ func (al *Alerting) ProvidersAlerts(healthResults *HealthResults) {
for provider, data := range healthResults.ProviderData {
specId := provider.SpecId
if al.allowedTimeGapVsReference > 0 {
latestBlock := healthResults.LatestBlocks[specId]
latestBlock, ok := healthResults.LatestBlocks[specId]
if !ok {
utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId})
return
}
if latestBlock > data.Block {
gap := latestBlock - data.Block
timeGap := time.Duration(gap*healthResults.Specs[specId].AverageBlockTime) * time.Millisecond
specHealthResult, ok := healthResults.Specs[specId]
if !ok {
utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId})
return
}
timeGap := time.Duration(gap*specHealthResult.AverageBlockTime) * time.Millisecond
if timeGap > al.allowedTimeGapVsReference {
attrs = append(attrs, AlertAttribute{entity: provider, data: fmt.Sprintf("block gap: %s/%s", utils.StrValue(data.Block), utils.StrValue(latestBlock))})
}
Expand Down
Loading