-
Notifications
You must be signed in to change notification settings - Fork 245
feat(tracing): adding block production tracing #2980
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
base: tracing-part-6
Are you sure you want to change the base?
Conversation
|
Claude finished @chatton's task in 1m 57s —— View job Comprehensive Code ReviewI've completed a thorough review of the block production tracing implementation. Overall, this is a well-structured addition that follows good design patterns. Here are my findings across multiple dimensions: ✅ Strengths1. Architecture & Design
2. Test Coverage
3. Code Quality
🔍 Issues & Recommendations1. Critical: Context Handling Bug in
|
| Category | Rating | Notes |
|---|---|---|
| Architecture | ⭐⭐⭐⭐⭐ | Excellent decorator pattern usage |
| Code Quality | ⭐⭐⭐⭐ | Good, but has the context.Background() issue |
| Testing | ⭐⭐⭐⭐⭐ | Comprehensive coverage |
| Security | ⭐⭐⭐⭐⭐ | No concerns |
| Performance | ⭐⭐⭐⭐⭐ | Minimal overhead |
| Documentation | ⭐⭐⭐ | Adequate but could be improved |
🎯 Action Items
Must Fix:
- ❗ Fix
ValidateBlockto acceptcontext.Context(critical for trace hierarchy)
Should Fix:
2. Standardize attribute naming conventions
3. Add package-level documentation
4. Improve inline comments for the blockProducer field
Nice to Have:
5. Add span events for better observability
6. Add test for span hierarchy
7. Consider sampling state root logging in production
✨ Conclusion
This is a solid implementation that demonstrates good software engineering practices. The decorator pattern is the right choice here, and the test coverage is exemplary. The main issue is the context.Background() bug in ValidateBlock, which should be fixed before merging. The other suggestions are improvements that would enhance maintainability and observability but aren't blocking.
Great work on maintaining clean separation of concerns and comprehensive testing! 🚀
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
Summary of ChangesHello @chatton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the observability of the block production process by integrating OpenTelemetry tracing. It achieves this through a clean architectural change, introducing a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tracing-part-6 #2980 +/- ##
==================================================
+ Coverage 58.19% 58.48% +0.28%
==================================================
Files 99 100 +1
Lines 9543 9619 +76
==================================================
+ Hits 5554 5626 +72
- Misses 3379 3382 +3
- Partials 610 611 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces OpenTelemetry tracing for the block production process, which is a great addition for observability. The implementation uses a clean decorator pattern by defining a BlockProducer interface and wrapping the Executor with a tracedBlockProducer. This approach is well-executed and enhances modularity. Additionally, the changes include several important fixes for context propagation, improving the overall robustness of the code. The new tracing logic is also well-tested. I have one suggestion to improve trace context propagation for the ValidateBlock step to ensure the trace hierarchy is correctly maintained.
| func (t *tracedBlockProducer) ValidateBlock(lastState types.State, header *types.SignedHeader, data *types.Data) error { | ||
| _, span := t.tracer.Start(context.Background(), "BlockExecutor.ValidateBlock", | ||
| trace.WithAttributes( | ||
| attribute.Int64("block.height", int64(header.Height())), | ||
| ), | ||
| ) | ||
| defer span.End() | ||
|
|
||
| err := t.inner.ValidateBlock(lastState, header, data) | ||
| if err != nil { | ||
| span.RecordError(err) | ||
| span.SetStatus(codes.Error, err.Error()) | ||
| } | ||
| return err | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using context.Background() here creates a new root span for ValidateBlock, which means it won't appear as a child of the ProduceBlock span in traces. This breaks the trace context propagation.
To fix this, the ValidateBlock method should accept a context.Context argument. This will require updating the BlockProducer interface and all its implementations (Executor, tracedBlockProducer, and mockBlockProducer in tests).
I've provided a suggestion for this file. You'll also need to update:
block/internal/executing/block_producer.go: Addctx context.ContexttoValidateBlockin the interface.block/internal/executing/executor.go: Addctxto theValidateBlockimplementation and pass it fromProduceBlock.block/internal/executing/tracing_test.go: Update themockBlockProducerto match the new interface.
This change will ensure ValidateBlock spans are correctly parented under ProduceBlock spans.
| func (t *tracedBlockProducer) ValidateBlock(lastState types.State, header *types.SignedHeader, data *types.Data) error { | |
| _, span := t.tracer.Start(context.Background(), "BlockExecutor.ValidateBlock", | |
| trace.WithAttributes( | |
| attribute.Int64("block.height", int64(header.Height())), | |
| ), | |
| ) | |
| defer span.End() | |
| err := t.inner.ValidateBlock(lastState, header, data) | |
| if err != nil { | |
| span.RecordError(err) | |
| span.SetStatus(codes.Error, err.Error()) | |
| } | |
| return err | |
| } | |
| func (t *tracedBlockProducer) ValidateBlock(ctx context.Context, lastState types.State, header *types.SignedHeader, data *types.Data) error { | |
| ctx, span := t.tracer.Start(ctx, "BlockExecutor.ValidateBlock", | |
| trace.WithAttributes( | |
| attribute.Int64("block.height", int64(header.Height())), | |
| ), | |
| ) | |
| defer span.End() | |
| err := t.inner.ValidateBlock(ctx, lastState, header, data) | |
| if err != nil { | |
| span.RecordError(err) | |
| span.SetStatus(codes.Error, err.Error()) | |
| } | |
| return err | |
| } |
Overview