Skip to content

Conversation

@gzliudan
Copy link
Collaborator

Proposed changes

Ref: ethereum#33749

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A



Follow-up to ethereum#33748

Same issue - ResettingTimer can be registered via loadOrRegister() but
GetAll() silently drops it during JSON export. The prometheus exporter
handles it fine (collector.go:70), so this is just an oversight in the
JSON path.

Note: ResettingTimer.Snapshot() resets the timer by design, which is
consistent with how the prometheus exporter uses it.
Copilot AI review requested due to automatic review settings February 10, 2026 07:47
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Adds support for exporting ResettingTimer metrics via StandardRegistry.GetAll(), enabling these timers to appear in registry JSON output and other GetAll() consumers.

Changes:

  • Extend StandardRegistry.GetAll() to serialize *ResettingTimer snapshots (count/min/max/mean + percentiles).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

case *ResettingTimer:
t := metric.Snapshot()
ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
values["count"] = t.Count()
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

In this new ResettingTimer branch, values["count"] is set to t.Count() (an int), whereas other metric types in GetAll use int64 counts (e.g., Counter/Meter/Timer). This creates inconsistent types in the returned map and can break callers that expect int64. Consider normalizing to int64 here (e.g., cast the count) for consistency with the rest of GetAll’s output.

Suggested change
values["count"] = t.Count()
values["count"] = int64(t.Count())

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +192
case *ResettingTimer:
t := metric.Snapshot()
ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
values["count"] = t.Count()
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ResettingTimer.Snapshot() resets the underlying timer; calling it from GetAll means any JSON marshalling of the registry (StandardRegistry.MarshalJSON uses GetAll) will also flush/reset these metrics. This can unintentionally drain samples if a debug/metrics endpoint is polled, and may interfere with other reporters that also call Snapshot on intervals. If the intent is only to expose current values, consider adding a non-resetting read method on ResettingTimer (or a dedicated "flush" path for reporters) so GetAll doesn’t have side effects.

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +200
case *ResettingTimer:
t := metric.Snapshot()
ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
values["count"] = t.Count()
values["min"] = t.Min()
values["max"] = t.Max()
values["mean"] = t.Mean()
values["median"] = ps[0]
values["75%"] = ps[1]
values["95%"] = ps[2]
values["99%"] = ps[3]
values["99.9%"] = ps[4]
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

GetAll/MarshalJSON currently has test coverage for counters, but this new ResettingTimer serialization path isn’t covered. Adding a unit test that registers a ResettingTimer, updates it, and asserts the JSON/GetAll output includes the expected fields (and behavior on subsequent calls, given Snapshot resets) would help prevent regressions.

Copilot uses AI. Check for mistakes.
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.

2 participants