Skip to content

Add metrics#26

Open
scx1332 wants to merge 8 commits intomainfrom
scx1332/metrics
Open

Add metrics#26
scx1332 wants to merge 8 commits intomainfrom
scx1332/metrics

Conversation

@scx1332
Copy link
Member

@scx1332 scx1332 commented Feb 19, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 blockStats struct 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)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
sqlitestore.go Outdated
Comment on lines 510 to 524
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))
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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))

Copilot uses AI. Check for mistakes.
scx1332 and others added 7 commits February 24, 2026 11:49
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants