/// <nodoc /> public static PipExecutionPerformanceEvent ToPipExecutionPerformanceEvent(this PipExecutionPerformanceEventData data) { var pipExecPerfEvent = new PipExecutionPerformanceEvent(); var pipExecPerformance = new PipExecutionPerformance(); pipExecPerformance.PipExecutionLevel = (int)data.ExecutionPerformance.ExecutionLevel; pipExecPerformance.ExecutionStart = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(data.ExecutionPerformance.ExecutionStart); pipExecPerformance.ExecutionStop = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(data.ExecutionPerformance.ExecutionStop); var processPipExecPerformance = new Xldb.Proto.ProcessPipExecutionPerformance(); var performance = data.ExecutionPerformance as ProcessPipExecutionPerformance; if (performance != null) { processPipExecPerformance.ProcessExecutionTime = Google.Protobuf.WellKnownTypes.Duration.FromTimeSpan(performance.ProcessExecutionTime); processPipExecPerformance.ReadCounters = new IOTypeCounters() { OperationCount = performance.IO.ReadCounters.OperationCount, TransferCOunt = performance.IO.ReadCounters.TransferCount }; processPipExecPerformance.WriteCounters = new IOTypeCounters() { OperationCount = performance.IO.WriteCounters.OperationCount, TransferCOunt = performance.IO.WriteCounters.TransferCount }; processPipExecPerformance.OtherCounters = new IOTypeCounters() { OperationCount = performance.IO.OtherCounters.OperationCount, TransferCOunt = performance.IO.OtherCounters.TransferCount }; processPipExecPerformance.UserTime = Google.Protobuf.WellKnownTypes.Duration.FromTimeSpan(performance.UserTime); processPipExecPerformance.KernelTime = Google.Protobuf.WellKnownTypes.Duration.FromTimeSpan(performance.KernelTime); processPipExecPerformance.PeakMemoryUsage = performance.PeakMemoryUsage; processPipExecPerformance.PeakMemoryUsageMb = performance.PeakMemoryUsageMb; processPipExecPerformance.NumberOfProcesses = performance.NumberOfProcesses; processPipExecPerformance.FileMonitoringViolationCounters = new FileMonitoringViolationCounters() { NumFileAccessesWhitelistedAndCacheable = performance.FileMonitoringViolations.NumFileAccessesWhitelistedAndCacheable, NumFileAccessesWhitelistedButNotCacheable = performance.FileMonitoringViolations.NumFileAccessesWhitelistedButNotCacheable, NumFileAccessViolationsNotWhitelisted = performance.FileMonitoringViolations.NumFileAccessViolationsNotWhitelisted }; processPipExecPerformance.Fingerprint = performance.Fingerprint.ToFingerprint(); if (performance.CacheDescriptorId.HasValue) { processPipExecPerformance.CacheDescriptorId = performance.CacheDescriptorId.Value; } } pipExecPerfEvent.WorkerID = data.ExecutionPerformance.WorkerId; pipExecPerfEvent.PipID = data.PipId.Value; pipExecPerfEvent.PipExecutionPerformance = pipExecPerformance; pipExecPerfEvent.ProcessPipExecutionPerformance = processPipExecPerformance; return(pipExecPerfEvent); }
private string GetPipExecutionLevel(PipExecutionPerformance exePerf) { return(exePerf == null ? ExeLevelNotCompleted : exePerf.ExecutionLevel.ToString()); }
/// <summary> /// Writes an execution entry. /// </summary> private void WriteExecutionEntry(PipId id, PipExecutionPerformance performance) { Contract.Requires(id.IsValid); Contract.Requires(performance != null); m_writer.WriteWhitespace(Environment.NewLine); m_writer.WriteStartObject(); { m_writer.WritePropertyName("pipId"); m_writer.WriteValue(id.Value); m_writer.WritePropertyName("runLevel"); m_writer.WriteValue(performance.ExecutionLevel.ToString()); m_writer.WritePropertyName("startTime"); m_writer.WriteValue(performance.ExecutionStart.ToFileTimeUtc()); m_writer.WritePropertyName("endTime"); m_writer.WriteValue(performance.ExecutionStop.ToFileTimeUtc()); m_writer.WritePropertyName("workerId"); m_writer.WriteValue(performance.WorkerId); var processPerformance = performance as ProcessPipExecutionPerformance; if (processPerformance != null) { m_writer.WritePropertyName("cacheFingerprint"); m_writer.WriteValue(processPerformance.Fingerprint.ToString()); if (processPerformance.CacheDescriptorId.HasValue) { m_writer.WritePropertyName("cacheDescriptorUniqueId"); m_writer.WriteValue(processPerformance.CacheDescriptorId.Value.ToString("X16", CultureInfo.InvariantCulture)); } if (processPerformance.ProcessExecutionTime != TimeSpan.Zero) { m_writer.WritePropertyName("processWallTime"); m_writer.WriteValue(processPerformance.ProcessExecutionTime.Ticks); } if (processPerformance.NumberOfProcesses > 1) { m_writer.WritePropertyName("processCount"); m_writer.WriteValue(processPerformance.NumberOfProcesses); } if (processPerformance.UserTime != TimeSpan.Zero) { m_writer.WritePropertyName("user"); m_writer.WriteValue(processPerformance.UserTime.Ticks); } if (processPerformance.KernelTime != TimeSpan.Zero) { m_writer.WritePropertyName("kernel"); m_writer.WriteValue(processPerformance.KernelTime.Ticks); } if (processPerformance.MemoryCounters.PeakWorkingSetMb != 0) { m_writer.WritePropertyName("peakMemoryMb"); m_writer.WriteValue(processPerformance.MemoryCounters.PeakWorkingSetMb); } if (processPerformance.IO.GetAggregateIO().TransferCount > 0) { m_writer.WritePropertyName("io"); m_writer.WriteStartObject(); { if (processPerformance.IO.ReadCounters.TransferCount != 0) { m_writer.WritePropertyName("bytesRead"); m_writer.WriteValue(processPerformance.IO.ReadCounters.TransferCount); } if (processPerformance.IO.WriteCounters.TransferCount != 0) { m_writer.WritePropertyName("bytesWritten"); m_writer.WriteValue(processPerformance.IO.WriteCounters.TransferCount); } if (processPerformance.IO.OtherCounters.TransferCount != 0) { m_writer.WritePropertyName("bytesMisc"); m_writer.WriteValue(processPerformance.IO.OtherCounters.TransferCount); } } m_writer.WriteEndObject(); } FileMonitoringViolationCounters monitoring = processPerformance.FileMonitoringViolations; if (monitoring.HasUncacheableFileAccesses) { m_writer.WritePropertyName("uncacheable"); m_writer.WriteValue(true); } if (monitoring.Total > 0) { m_writer.WritePropertyName("fileMonitoringViolations"); m_writer.WriteStartObject(); { m_writer.WritePropertyName("total"); m_writer.WriteValue(monitoring.Total); if (monitoring.TotalAllowlisted > 0) { m_writer.WritePropertyName("allowlisted"); m_writer.WriteValue(monitoring.TotalAllowlisted); } if (monitoring.NumFileAccessesAllowlistedButNotCacheable > 0) { m_writer.WritePropertyName("allowlistedButNotCacheable"); m_writer.WriteValue(monitoring.NumFileAccessesAllowlistedButNotCacheable); } } m_writer.WriteEndObject(); } } } m_writer.WriteEndObject(); }