From d25e0b7a199a5f4a3d92a7ed132117d0ea4e637b Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 14 Oct 2022 12:44:11 -0700 Subject: [PATCH] update init values --- src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs b/src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs index e5e5242775..745cbb76fb 100644 --- a/src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs +++ b/src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs @@ -36,12 +36,16 @@ internal sealed class ProcessMetrics private IEnumerable> cpuUtilization; // vars for calculating CPU utilization - private DateTime lastCollectedTimeStampUtc = DateTime.UtcNow; + private DateTime lastCollectedTimeStampUtc; private double lastCollectedUserProcessorTime; private double lastCollectedPrivilegedProcessorTime; public ProcessMetrics(ProcessInstrumentationOptions options) { + this.lastCollectedTimeStampUtc = DateTime.UtcNow; + this.lastCollectedUserProcessorTime = this.currentProcess.UserProcessorTime.TotalSeconds; + this.lastCollectedUserProcessorTime = this.currentProcess.PrivilegedProcessorTime.TotalSeconds; + // TODO: change to ObservableUpDownCounter this.MeterInstance.CreateObservableGauge( "process.memory.usage",