diff --git a/Backtrace/Model/JsonData/BacktraceAttributes.cs b/Backtrace/Model/JsonData/BacktraceAttributes.cs index a6ea306..72eedac 100644 --- a/Backtrace/Model/JsonData/BacktraceAttributes.cs +++ b/Backtrace/Model/JsonData/BacktraceAttributes.cs @@ -232,13 +232,21 @@ private void SetProcessAttributes() { return; } - //How long the application has been running in secounds - var processAge = Math.Round(process.TotalProcessorTime.TotalSeconds); - var totalProcessAge = unchecked((long)processAge); - if (totalProcessAge > 0) + try + { + //How long the application has been running in secounds + var processAge = Math.Round(process.TotalProcessorTime.TotalSeconds); + var totalProcessAge = unchecked((long)processAge); + if (totalProcessAge > 0) + { + Attributes["process.age"] = totalProcessAge; + } + } + catch (NotSupportedException) { - Attributes["process.age"] = totalProcessAge; + Trace.TraceWarning($"Cannot retrieve process age - TotalProcessorTime is not supported"); } + try { Attributes["cpu.process.count"] = Process.GetProcesses().Count(); @@ -275,7 +283,7 @@ private void SetProcessAttributes() Attributes["vm.vma.peak"] = peakVirtualMemorySize; } } - catch (PlatformNotSupportedException) + catch (NotSupportedException) { Trace.TraceWarning($"Cannot retrieve information about process memory - platform not supported"); }