Skip to content

cpuexporter: fix sum_stats mutation, nil dereference and timestamp unit#469

Closed
lneto wants to merge 1 commit intomasterfrom
claude_cpuexporter
Closed

cpuexporter: fix sum_stats mutation, nil dereference and timestamp unit#469
lneto wants to merge 1 commit intomasterfrom
claude_cpuexporter

Conversation

@lneto
Copy link
Copy Markdown
Contributor

@lneto lneto commented Mar 8, 2026

No description provided.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lneto lneto requested a review from endersonmaia March 8, 2026 22:27
Comment thread examples/cpuexporter.lua
session:send(cpu_metrics())
end

-- Initial sample
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had this so that the first call to the metrics socket already returns the percentage, since I need at least two samples to calculate the percentage.

Comment thread examples/cpuexporter.lua
local metrics = ""
local ts_ms = linux.time() // 1000 -- Convert to milliseconds (FIXME: note sure if this conversion is necessary)
local usage_data = cpu_usage() -- Call once and store the result
local ts_ms = linux.time() // 1000000
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the precision was right but the comment was wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

actually the fix is correct, prometheus expects millisecods.

Copy link
Copy Markdown
Contributor

@endersonmaia endersonmaia left a comment

Choose a reason for hiding this comment

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

Made two inline comments, but nothing blocking.

@lneto
Copy link
Copy Markdown
Contributor Author

lneto commented Mar 10, 2026

Made two inline comments, but nothing blocking.

will work on them.. thanks! btw, can you summarize anything is pending here? I will try to fix it with claude ;-)

@lneto lneto closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants