Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds metrics tracking to the SQLiteStore's event processing pipeline using the go-ethereum metrics package. The metrics track operation counts (creates, updates, deletes, extends, owner changes), batch processing success/failure rates, and operation timing.
Changes:
- Added seven global metrics variables for tracking operations and timing using go-ethereum's metrics package
- Introduced a
blockStatsstruct to track operation counts per block - Refactored from simple local counter variables to a map-based tracking system that preserves per-block statistics
- Metrics are updated after successful transaction commits to ensure accuracy
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| startTime := time.Now() | ||
|
|
||
| metricOperationStarted.Inc(1) |
There was a problem hiding this comment.
The metricOperationStarted counter is incremented before checking if any blocks will actually be processed. If all blocks in the batch are skipped (line 165-167), the batch will still show as both started and successful (line 528), even though no database modifications occurred. While this accurately tracks batch processing, it may not reflect actual data processing work. Consider whether the metric should track batches processed or blocks processed, and adjust accordingly for clearer observability.
sqlitestore.go
Outdated
| if s.creates > 0 { | ||
| metricCreates.Inc(int64(s.creates)) | ||
| } | ||
| if s.updates > 0 { | ||
| metricUpdates.Inc(int64(s.updates)) | ||
| } | ||
| if s.deletes > 0 { | ||
| metricDeletes.Inc(int64(s.deletes)) | ||
| } | ||
| if s.extends > 0 { | ||
| metricExtends.Inc(int64(s.extends)) | ||
| } | ||
| if s.ownerChanges > 0 { | ||
| metricOwnerChanges.Inc(int64(s.ownerChanges)) | ||
| } |
There was a problem hiding this comment.
The zero checks (e.g., if s.creates > 0) before incrementing metrics are unnecessary. Counter.Inc() can safely be called with 0, and these conditional checks add complexity without providing any benefit. Consider removing these checks and unconditionally incrementing the metrics with the count values to simplify the code.
| if s.creates > 0 { | |
| metricCreates.Inc(int64(s.creates)) | |
| } | |
| if s.updates > 0 { | |
| metricUpdates.Inc(int64(s.updates)) | |
| } | |
| if s.deletes > 0 { | |
| metricDeletes.Inc(int64(s.deletes)) | |
| } | |
| if s.extends > 0 { | |
| metricExtends.Inc(int64(s.extends)) | |
| } | |
| if s.ownerChanges > 0 { | |
| metricOwnerChanges.Inc(int64(s.ownerChanges)) | |
| } | |
| metricCreates.Inc(int64(s.creates)) | |
| metricUpdates.Inc(int64(s.updates)) | |
| metricDeletes.Inc(int64(s.deletes)) | |
| metricExtends.Inc(int64(s.extends)) | |
| metricOwnerChanges.Inc(int64(s.ownerChanges)) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: scx1332 <27012161+scx1332@users.noreply.github.com>
…entry [WIP] Fix missing go.sum entry for gopsutil package
No description provided.