Skip to content

Commit 0780db0

Browse files
authored
Fix CPU metrics (#2413)
1 parent 9f9be7b commit 0780db0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

agent/azure-monitor-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/utils/CpuPerformanceCounterCalculator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public Double getCpuPercentage() {
5151
if (prevUpTime > 0L && upTime > prevUpTime) {
5252
long elapsedCpu = processCpuTime - prevProcessCpuTime;
5353
long elapsedTime = upTime - prevUpTime;
54+
prevUpTime = upTime;
55+
prevProcessCpuTime = processCpuTime;
5456
// if this looks weird, here's another way to write it:
5557
// (elapsedCpu / 1000000.0) / elapsedTime / 100.0
5658
return elapsedCpu / (elapsedTime * 10_000.0);

0 commit comments

Comments
 (0)