Skip to content

Change process.uptime from TimeGauge to FunctionCounter#7458

Open
mgustimz wants to merge 1 commit into
micrometer-metrics:mainfrom
mgustimz:issue/7346-process-uptime-functioncounter
Open

Change process.uptime from TimeGauge to FunctionCounter#7458
mgustimz wants to merge 1 commit into
micrometer-metrics:mainfrom
mgustimz:issue/7346-process-uptime-functioncounter

Conversation

@mgustimz
Copy link
Copy Markdown

@mgustimz mgustimz commented May 2, 2026

Summary

Changed process.uptime meter from TimeGauge to FunctionCounter in UptimeMetrics. Semantically, process.uptime is a monotonically increasing accumulated value, making FunctionCounter the more appropriate meter type — matching the discussion in PR #7297.

What changed

UptimeMetrics.java

  • Changed meter type from TimeGauge to FunctionCounter
  • Added .baseUnit("ms") for consistency with the native unit returned by RuntimeMXBean::getUptime

UptimeMetricsTest.java

  • Updated test assertions from .timeGauge() to .functionCounter()
  • Adjusted expected value from 1.337 (converted to seconds) to 1337.0 (raw milliseconds from mock)

Breaking change note

For registries that treat gauges and counters differently, this is a breaking change for process.uptime. Users monitoring this metric may need to update their dashboards or alerting rules. The issue #7346 notes this was a consideration and it may be appropriate to wait for 2.0 for this change, but the semantic correctness makes it worth proposing now.

Fixes

Fixes #7346

@mgustimz mgustimz marked this pull request as draft May 2, 2026 07:32
@mgustimz mgustimz marked this pull request as ready for review May 2, 2026 14:41
The process.uptime metric semantically represents a monotonically increasing
accumulated value, making FunctionCounter a more appropriate choice than
TimeGauge. This aligns with the discussion in PR micrometer-metrics#7297.

Fixes micrometer-metrics#7346

Signed-off-by: Sehz <sehz@openclaw.local>
@mgustimz mgustimz force-pushed the issue/7346-process-uptime-functioncounter branch from baa4133 to b66e7ae Compare May 2, 2026 15:03
@jonatan-ivanov
Copy link
Copy Markdown
Member

Thank you for the PR!

If this PR was (at least partly) created by some kind of AI tooling, could you please tell us what tool/tools you used so that we can keep the records of it?

I think this should wait for #7329 but also, as the original issue mentioned (#7346) as well as the description of this PR: this is a breaking change and I think we should not do this as-is. At least we should introduce some kind of an opt-in mechanism with probably deprecating the old one: #7311

@jonatan-ivanov jonatan-ivanov added enhancement A general enhancement blocked An issue that's blocked on an external project change labels May 4, 2026
@mgustimz
Copy link
Copy Markdown
Author

mgustimz commented May 5, 2026

Thank you for the review!

Yeah, this PR was created with assistance from an AI tool (OpenClaw). I'll note that going forward.

Agreed on waiting for #7329 and the opt-in mechanism. The semantic correctness of FunctionCounter for a monotonically increasing value is clear, but you're right that a breaking change deserves a proper deprecation path rather than a silent swap. I'll leave this PR open as a reference and happy to implement the opt-in approach if #7311 moves forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked An issue that's blocked on an external project change enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change process.uptime to FunctionCounter in UptimeMetrics

2 participants