Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 /// <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;
         }
     }
 }
Ejemplo n.º 3
0
 /// <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;
         }
     }
 }
Ejemplo n.º 4
0
 public CosmosSystemInfo(
     CpuLoadHistory cpuLoadHistory)
 {
     this.CpuLoadHistory = cpuLoadHistory ?? throw new ArgumentNullException(nameof(cpuLoadHistory));
 }