public override void Visit(CosmosSystemInfo processInfo) { this.jsonWriter.WriteStartObject(); this.jsonWriter.WritePropertyName("Id"); this.jsonWriter.WriteValue("SystemInfo"); this.jsonWriter.WritePropertyName("CpuHistory"); CpuLoadHistory cpuLoadHistory = processInfo.CpuLoadHistory; this.jsonWriter.WriteValue(cpuLoadHistory.ToString()); this.jsonWriter.WriteEndObject(); }
/// <summary> /// The diagnostics should never block a request, and is a best attempt /// If the CPU load history fails then don't try it in the future. /// </summary> public void RecordCpuDiagnostics(RequestMessage request) { if (this.isCpuMonitorEnabled) { try { CpuLoadHistory cpuHistory = this.cpuMonitor.GetCpuLoad(); if (cpuHistory != null) { request.DiagnosticsContext.AddDiagnosticsInternal(new CosmosSystemInfo(cpuHistory)); } } catch (Exception) { this.isCpuMonitorEnabled = false; } } }
/// <summary> /// The diagnostics should never block a request, and is a best attempt /// If the CPU load history fails then don't try it in the future. /// </summary> public void RecordCpuDiagnostics(RequestMessage request) { if (this.isCpuMonitorEnabled) { try { CpuLoadHistory cpuHistory = this.cpuMonitor.GetCpuLoad(); if (cpuHistory != null) { request.Trace.AddDatum( "CPU Load History", new CpuHistoryTraceDatum(cpuHistory)); } } catch (Exception) { this.isCpuMonitorEnabled = false; } } }
public CosmosSystemInfo( CpuLoadHistory cpuLoadHistory) { this.CpuLoadHistory = cpuLoadHistory ?? throw new ArgumentNullException(nameof(cpuLoadHistory)); }