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

fix(core): correctly set Listener.handleNewSignedBlockfrom's spanStatus from returned error or panics #3817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

odeke-em
Copy link
Contributor

@odeke-em odeke-em commented Oct 6, 2024

This change ensures that if a panic occurs, that span.RecordError correctly records it and then if an error is returned that span.Status correctly captures and records it.

Fixes #3814

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 46.41%. Comparing base (2469e7a) to head (fbc937c).
Report is 335 commits behind head on main.

Files with missing lines Patch % Lines
core/listener.go 40.00% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3817      +/-   ##
==========================================
+ Coverage   44.83%   46.41%   +1.57%     
==========================================
  Files         265      314      +49     
  Lines       14620    18151    +3531     
==========================================
+ Hits         6555     8424    +1869     
- Misses       7313     8709    +1396     
- Partials      752     1018     +266     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wondertan Wondertan added the kind:fix Attached to bug-fixing PRs label Oct 7, 2024
@Wondertan
Copy link
Member

There is a lint issue and LGTM

@odeke-em odeke-em force-pushed the core-correctly-set-Span.Status branch from b44a7da to 563f827 Compare October 7, 2024 10:08
@odeke-em
Copy link
Contributor Author

odeke-em commented Oct 7, 2024

Thanks @Wondertan! Kindly help me take a look again.

@odeke-em odeke-em force-pushed the core-correctly-set-Span.Status branch from 563f827 to 40598bc Compare October 7, 2024 10:20
…us from returned error or panics

This change ensures that if a panic occurs, that span.RecordError
correctly records it and then if an error is returned that span.Status
correctly captures and records it.

Fixes celestiaorg#3814
@odeke-em odeke-em force-pushed the core-correctly-set-Span.Status branch from 40598bc to fbc937c Compare October 7, 2024 10:34
@odeke-em
Copy link
Contributor Author

odeke-em commented Oct 7, 2024

All checks passing, we are good to go @Wondertan

Comment on lines +240 to +241
// Record the "exception"/panic.
span.RecordError(rerr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move it out of recover block and put it instead of SetStatus, while SetStatus goes to every individual error check.

As per otel API these are used together and not only on recovering. RecordError does what it says, while SetStatus has a description on it to put next to the operation.

So extendBlock would become

eds, err := extendBlock(b.Data, b.Header.Version.App)
	if err != nil {
               span.SetStatus(codes.Error, "extendBlock")
		return fmt.Errorf("extending block data: %w", err)
	}
and so on

Comment on lines +251 to +253
if r != nil { // Re-panic
panic(r)
}
Copy link
Member

@Wondertan Wondertan Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to avoid re-panicing, but actually we should so that the panic during sync doesn't go unnoticed
[not actionable]

@renaynay
Copy link
Member

@odeke-em would you be able to implement the changes requested by Hlib here or should we take over the PR from you? If we don't hear back in a week, we'll take it over. Thanks!

@odeke-em
Copy link
Contributor Author

Hey @renaynay, please feel free to take over. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issues created by non node team members kind:fix Attached to bug-fixing PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core: Listener.handleNewSignedBlock doesn't correctly record any errors to trace span
4 participants