Skip to content

Commit

Permalink
update metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
randyahx committed Aug 8, 2023
1 parent 98d3858 commit 1a8a98e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions submitter/tx_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (s *TxSubmitter) SubmitTransactionLoop() {
}
err = s.submitForSingleEvent(event, attestPeriodEnd)
if err != nil {
s.metricService.IncSubmitterErr()
logging.Logger.Errorf("tx submitter err", err)
continue
}
Expand Down Expand Up @@ -114,6 +113,7 @@ func (s *TxSubmitter) submitForSingleEvent(event *model.Event, attestPeriodEnd u
// Calculate event hash and use it to fetch votes and validator bitset
aggregatedSignature, valBitSet, err := s.getSignatureAndBitSet(event)
if err != nil {
s.metricService.IncSubmitterErr()
return err
}
return s.submitTransactionLoop(event, attestPeriodEnd, aggregatedSignature, valBitSet)
Expand Down Expand Up @@ -160,6 +160,7 @@ func (s *TxSubmitter) submitTransactionLoop(event *model.Event, attestPeriodEnd
}

if submittedAttempts > common.MaxSubmitAttempts {
s.metricService.IncSubmitterErr()
return fmt.Errorf("submitter exceeded max submit attempts for challengeId: %d", event.ChallengeId)
}

Expand All @@ -183,17 +184,22 @@ func (s *TxSubmitter) submitTransactionLoop(event *model.Event, attestPeriodEnd
// Submit transaction
attestRes, err := s.executor.AttestChallenge(s.executor.GetAddr(), event.ChallengerAddress, event.SpOperatorAddress, event.ChallengeId, math.NewUintFromString(event.ObjectId), voteResult, valBitSet.Bytes(), aggregatedSignature, txOpts)
if err != nil || !attestRes {
logging.Logger.Errorf("submitter failed for challengeId: %d, attempts: %d, err=%+v", event.ChallengeId, submittedAttempts, err.Error())
submittedAttempts++
time.Sleep(TxSubmitInterval)
continue
}
// Update event status to include in Attest Monitor
err = s.DataProvider.UpdateEventStatus(event.ChallengeId, model.Submitted)
if err != nil {
logging.Logger.Errorf("submitter succeeded in attesting but failed to update database, err=%+v", err.Error())
continue
}

elaspedTime := time.Since(startTime)
s.metricService.SetSubmitterDuration(elaspedTime)
s.metricService.IncSubmittedChallenges()
logging.Logger.Infof("submitter metrics increased for challengeId %d", event.ChallengeId)
logging.Logger.Infof("submitter metrics increased for challengeId %d, elasped time %+v", event.ChallengeId, elaspedTime)
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion vote/vote_broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (p *VoteBroadcaster) BroadcastVotesLoop() {
// Incrementing this before broadcasting to prevent the same challengeID from being incremented multiple times
// does not mean that it has been successfully broadcasted, check error metrics for broadcast errors.
p.metricService.IncBroadcastedChallenges()
logging.Logger.Infof("broadcaster metric increased for challengeId: %d", event.ChallengeId)
logging.Logger.Infof("broadcaster metrics increased for challengeId %d", event.ChallengeId)
}

err = p.broadcastForSingleEvent(localVote.(*votepool.Vote), event)
Expand Down
2 changes: 1 addition & 1 deletion vote/vote_collator.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (p *VoteCollator) collateForSingleEvent(event *model.Event) error {
elaspedTime := time.Since(startTime)
p.metricService.SetCollatorDuration(elaspedTime)
p.metricService.IncCollatedChallenges()
logging.Logger.Infof("collator metrics increased for challengeId %d", event.ChallengeId)
logging.Logger.Infof("collator metrics increased for challengeId %d, elasped time %+v", event.ChallengeId, elaspedTime)
logging.Logger.Infof("collator completed time for challengeId: %d %s", event.ChallengeId, time.Now().Format("15:04:05.000000"))
return nil
}
Expand Down

0 comments on commit 1a8a98e

Please sign in to comment.