From 4e76e6938accdfe7af27a15fa96ce33c211f91b3 Mon Sep 17 00:00:00 2001 From: amdmax Date: Fri, 3 Jun 2022 17:44:21 +0500 Subject: [PATCH 1/3] fix PercentTimeinGC metric Signed-off-by: Max Trunov --- collector/netframework_clrmemory.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/collector/netframework_clrmemory.go b/collector/netframework_clrmemory.go index 2e363621..f5087b9a 100644 --- a/collector/netframework_clrmemory.go +++ b/collector/netframework_clrmemory.go @@ -144,6 +144,7 @@ type Win32_PerfRawData_NETFramework_NETCLRMemory struct { NumberTotalcommittedBytes uint64 NumberTotalreservedBytes uint64 PercentTimeinGC uint32 + PercentTimeinGC_base uint32 ProcessID uint64 PromotedFinalizationMemoryfromGen0 uint64 PromotedMemoryfromGen0 uint64 @@ -294,7 +295,7 @@ func (c *NETFramework_NETCLRMemoryCollector) collect(ch chan<- prometheus.Metric ch <- prometheus.MustNewConstMetric( c.TimeinGC, prometheus.GaugeValue, - float64(process.PercentTimeinGC)/float64(process.Frequency_PerfTime), + float64(100*process.PercentTimeinGC)/float64(process.PercentTimeinGC_base), process.Name, ) } From 6d506887cd1e7d86f9647f8d2f826064cdd547d8 Mon Sep 17 00:00:00 2001 From: amdmax Date: Mon, 5 Sep 2022 09:12:18 +0500 Subject: [PATCH 2/3] Add comments to changes Signed-off-by: Max Trunov --- collector/netframework_clrmemory.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collector/netframework_clrmemory.go b/collector/netframework_clrmemory.go index f5087b9a..9fa317a2 100644 --- a/collector/netframework_clrmemory.go +++ b/collector/netframework_clrmemory.go @@ -143,7 +143,11 @@ type Win32_PerfRawData_NETFramework_NETCLRMemory struct { NumberofSinkBlocksinuse uint64 NumberTotalcommittedBytes uint64 NumberTotalreservedBytes uint64 + // PercentTimeinGC has countertype=PERF_RAW_FRACTION. + // Formula: (100 * CounterValue) / BaseValue + // By docs https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/ms974615(v=msdn.10)#perf_raw_fraction PercentTimeinGC uint32 + // BaseValue is just a "magic" number used to make the calculation come out right. PercentTimeinGC_base uint32 ProcessID uint64 PromotedFinalizationMemoryfromGen0 uint64 From 2ef7c5604a1fac61347e314d32a5a6a87a891218 Mon Sep 17 00:00:00 2001 From: Max Trunov Date: Fri, 9 Sep 2022 17:11:37 +0500 Subject: [PATCH 3/3] gofmt netframework_clrmemory.go Signed-off-by: Max Trunov --- collector/netframework_clrmemory.go | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/collector/netframework_clrmemory.go b/collector/netframework_clrmemory.go index 9fa317a2..74fbe1fe 100644 --- a/collector/netframework_clrmemory.go +++ b/collector/netframework_clrmemory.go @@ -124,29 +124,29 @@ func (c *NETFramework_NETCLRMemoryCollector) Collect(ctx *ScrapeContext, ch chan type Win32_PerfRawData_NETFramework_NETCLRMemory struct { Name string - AllocatedBytesPersec uint64 - FinalizationSurvivors uint64 - Frequency_PerfTime uint64 - Gen0heapsize uint64 - Gen0PromotedBytesPerSec uint64 - Gen1heapsize uint64 - Gen1PromotedBytesPerSec uint64 - Gen2heapsize uint64 - LargeObjectHeapsize uint64 - NumberBytesinallHeaps uint64 - NumberGCHandles uint64 - NumberGen0Collections uint64 - NumberGen1Collections uint64 - NumberGen2Collections uint64 - NumberInducedGC uint64 - NumberofPinnedObjects uint64 - NumberofSinkBlocksinuse uint64 - NumberTotalcommittedBytes uint64 - NumberTotalreservedBytes uint64 + AllocatedBytesPersec uint64 + FinalizationSurvivors uint64 + Frequency_PerfTime uint64 + Gen0heapsize uint64 + Gen0PromotedBytesPerSec uint64 + Gen1heapsize uint64 + Gen1PromotedBytesPerSec uint64 + Gen2heapsize uint64 + LargeObjectHeapsize uint64 + NumberBytesinallHeaps uint64 + NumberGCHandles uint64 + NumberGen0Collections uint64 + NumberGen1Collections uint64 + NumberGen2Collections uint64 + NumberInducedGC uint64 + NumberofPinnedObjects uint64 + NumberofSinkBlocksinuse uint64 + NumberTotalcommittedBytes uint64 + NumberTotalreservedBytes uint64 // PercentTimeinGC has countertype=PERF_RAW_FRACTION. // Formula: (100 * CounterValue) / BaseValue // By docs https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/ms974615(v=msdn.10)#perf_raw_fraction - PercentTimeinGC uint32 + PercentTimeinGC uint32 // BaseValue is just a "magic" number used to make the calculation come out right. PercentTimeinGC_base uint32 ProcessID uint64