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
Added virtual memory scraper to hostmetrics receiver #989
Added virtual memory scraper to hostmetrics receiver #989
Conversation
a936a5b
to
408d495
Compare
Codecov Report
@@ Coverage Diff @@
## master #989 +/- ##
==========================================
+ Coverage 85.63% 85.73% +0.10%
==========================================
Files 189 192 +3
Lines 13167 13275 +108
==========================================
+ Hits 11275 11381 +106
- Misses 1439 1441 +2
Partials 453 453
Continue to review full report at Codecov.
|
receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_constants.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_constants.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_constants.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_constants.go
Outdated
Show resolved
Hide resolved
a6ca503
to
ff8690f
Compare
I made some pretty significant changes as per Jay's comments if you could take another look:
|
...r/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_scraper_windows.go
Show resolved
Hide resolved
var ( | ||
modPsapi = windows.NewLazySystemDLL("psapi.dll") | ||
procEnumPageFilesW = modPsapi.NewProc("EnumPageFilesW") | ||
) |
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.
Ideally everything in this file will get upstreamed to gopsutil
. I'll create a PR in that repo as well and update here if that gets merged. Added note to #973.
ff8690f
to
1972a0d
Compare
Regarding coverage, is it possible to override the new "codecov/patch" gate in some cases? The problem here is the generated cover report is only based on Linux, and this PR pretty much exclusively adds code & tests for Windows, with a few lines of scaffolding for Linux. It would seem a bit overkill to hack this PR to increase coverage for that (see the codecode diff). Coverage of the virtualmemoryscraper package on Windows is: > go-acc .
ok go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper 0.392s coverage: 95.3 Edit: I've added Linux support for virtual memory metrics in this PR, so this comment isn't relevant anymore |
1972a0d
to
b3fca5c
Compare
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.
Looks good!
receiver/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/pagefile_windows.go
Outdated
Show resolved
Hide resolved
...r/hostmetricsreceiver/internal/scraper/virtualmemoryscraper/virtualmemory_scraper_windows.go
Show resolved
Hide resolved
f9ec8bc
to
aca3553
Compare
idps := metric.Int64DataPoints() | ||
idps.Resize(1) | ||
initializePageFaultDataPoint(idps.At(0), startTime, minorTypeLabelValue, int64(swap.PgFault)) | ||
// TODO add swap.PgMajFault once available in gopsutil |
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.
|
||
// Initialize | ||
func (s *scraper) Initialize(_ context.Context) error { | ||
s.startTime = pdata.TimestampUnixNano(uint64(time.Now().UnixNano())) |
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.
Note since we are deriving the counter from per second values, the counter essentially starts from when we take the first reading, thus why I set this to the current time here. I believe that's correct?
02aad64
to
9d70736
Compare
I did one more pass to this PR adding support for Linux metrics (as a second commit). Note the comment above about coverage isn't relevant anymore since I made this change. @jrcamp - If you could pls take a look at the Linux changes, in particular:
|
9d70736
to
d6940e5
Compare
Looks correct to me based on kernel docs. Actually their SwapFree description is confusing. It makes it sound like something different but looking at a Linux VM it appears to be what it sounds like from the name (unused swap space). The rest sounds good! |
@bogdandrutu ptal |
@@ -39,7 +39,7 @@ func TestStartSampling(t *testing.T) { | |||
// override the processor queue length perf counter with a mock | |||
// that will ensure a positive value is returned | |||
assert.IsType(t, &pdh.PerfCounter{}, samplerInstance.processorQueueLengthCounter) | |||
samplerInstance.processorQueueLengthCounter = pdh.NewMockPerfCounter(100) | |||
samplerInstance.processorQueueLengthCounter = pdh.NewMockPerfCounter(100.0) |
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.
In the future better to send changes unrelated to the main PR separately.
* Change default Sampler to ParentOrElse(AlwaysOn) * add note to changelog
Link to tracking Issue:
#847
Description:
Added virtual memory scraper to the hostmetricsreceiver, which has significanly differnet logic for Windows & Linux.
Screenshot of Metrics on Windows: