Skip to content

Commit

Permalink
telemetry: add BlockAcceptedEventDetails.ReceivedAt to complement Val…
Browse files Browse the repository at this point in the history
…idatedAt (#4583)
  • Loading branch information
cce authored Sep 24, 2022
1 parent 96a1e1b commit 099392a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 30 deletions.
2 changes: 2 additions & 0 deletions agreement/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (a ensureAction) do(ctx context.Context, s *Service) {
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,
ReceivedAt: a.Payload.receivedAt,
PreValidated: true,
PropBufLen: uint64(len(s.demux.rawProposals)),
VoteBufLen: uint64(len(s.demux.rawVotes)),
Expand All @@ -250,6 +251,7 @@ func (a ensureAction) do(ctx context.Context, s *Service) {
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,
ReceivedAt: a.Payload.receivedAt,
PreValidated: false,
PropBufLen: uint64(len(s.demux.rawProposals)),
VoteBufLen: uint64(len(s.demux.rawVotes)),
Expand Down
5 changes: 4 additions & 1 deletion agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Durat
proto, err := d.ledger.ConsensusVersion(ParamsRound(e.ConsensusRound()))
e = e.AttachConsensusVersion(ConsensusVersionView{Err: makeSerErr(err), Version: proto})

if e.t() == payloadVerified {
switch e.t() {
case payloadVerified:
e = e.(messageEvent).AttachValidatedAt(s.Clock.Since())
case payloadPresent:
e = e.(messageEvent).AttachReceivedAt(s.Clock.Since())
}
}()

Expand Down
5 changes: 5 additions & 0 deletions agreement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,3 +938,8 @@ func (e messageEvent) AttachValidatedAt(d time.Duration) messageEvent {
e.Input.Proposal.validatedAt = d
return e
}

func (e messageEvent) AttachReceivedAt(d time.Duration) messageEvent {
e.Input.Proposal.receivedAt = d
return e
}
58 changes: 29 additions & 29 deletions agreement/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ type proposal struct {
// validated (and thus was ready to be delivered to the state
// machine), relative to the zero of that round.
validatedAt time.Duration

// receivedAt indicates the time at which this proposal was
// delivered to the agreement package (as a messageEvent),
// relative to the zero of that round.
receivedAt time.Duration
}

func makeProposal(ve ValidatedBlock, pf crypto.VrfProof, origPer period, origProp basics.Address) proposal {
Expand Down
1 change: 1 addition & 0 deletions logging/telemetryspec/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type BlockAcceptedEventDetails struct {
Hash string
Round uint64
ValidatedAt time.Duration
ReceivedAt time.Duration
PreValidated bool
PropBufLen uint64
VoteBufLen uint64
Expand Down

0 comments on commit 099392a

Please sign in to comment.