-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[receiver/hostmetrics] Collect cpu utilization metric #7130
[receiver/hostmetrics] Collect cpu utilization metric #7130
Conversation
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/metadata.yaml
Outdated
Show resolved
Hide resolved
cpuUtilizations, err := s.ucal.Calculate(now, cpuTimes) | ||
if err != nil { | ||
return md, scrapererror.NewPartialScrapeError(err, metricsLen) | ||
} | ||
for _, cpuUtilization := range cpuUtilizations { | ||
s.recordCPUUtilization(now, cpuUtilization) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like unnecessary slice of utilizations, should we simply pass a func pointer recordCPUUtilization
to the ucal
so it calls into the right func?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way the calculator just handles the part of calculation and the scrapper it is the responsible of recording making it more decoupled and easier to test. Still, it adds this overhead so I guess that it is a trade-off.
If you think that this kind of overhead needs to be avoided as much as possible, I can work on it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @bogdandrutu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do believe that unnecessary overhead is good to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I added the recorder
to the calculator to record it as soon as it is calculated. 8593685
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @bogdandrutu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bogdandrutu 👋 I already moved the recordCPUUtilization
functionality inside the calculator to avoid overhead. Let me know if this looks better now 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bogdandrutu , reading the specification discussion about having both metrics, seems that it can make sense to have both metrics and this could be a good candidate to be disabled by default. I have made another commit with this last change.
What do you think?
Is |
I also asked for clarification in the spec open-telemetry/semantic-conventions#647 |
@tigrannajaryan my understanding was that |
Sounds good. I think the spec needs a clarification but the metrics are indeed different. |
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/cpu_utilization_calculator.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/cpu_utilization_calculator.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper_test.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper_test.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/cpu_scraper_linux.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/cpuscraper/ucal/cpu_utilization_calculator.go
Outdated
Show resolved
Hide resolved
@rubenruizdegauna sorry for the delay. Can you please rebase, otherwise it looks good to me |
NP :) Rebased and all tests ✅ in my fork. Thanks @dmitryax !! |
I think this PR is good to be merged. @bogdandrutu WDYT? |
Hi @bogdandrutu , this PR has been approved and checks are ✅ . Do you think it can be merged? Thanks! |
Description:
This PR adds
system.cpu.utilization
tohostmetricsreceiver
Link to tracking Issue:
#6221
Testing:
Tests added for existing CPU scrapper and for the added CPU Utilization calculator
Documentation:
New metrics added to Documentation