public Task Handle(HeartbeatEvent ev)
 {
     return _sender.Publish(ev);
 }
Esempio n. 2
0
        private HeartbeatEvent CreateHeartbeatEvent()
        {
            var process = Process.GetCurrentProcess();

            PerformanceCounterDto[] performanceCounterHistory;
            lock (_mutex)
            {
                performanceCounterHistory = _performanceCounterHistory.ToArray();
                _performanceCounterHistory.Clear();
            }

            var heartbeatEvent = new HeartbeatEvent
                                 {
                                     Timestamp = _clock.UtcNow,
                                     ProcessId = process.Id,
                                     ProcessName = process.ProcessName,
                                     MachineName = Environment.MachineName,
                                     OSVersion = Environment.OSVersion.VersionString,
                                     ProcessorCount = Environment.ProcessorCount,
                                     StartTime = new DateTimeOffset(process.StartTime),
                                     UserProcessorTime = process.UserProcessorTime,
                                     TotalProcessorTime = process.TotalProcessorTime,
                                     WorkingSet64 = process.WorkingSet64,
                                     PeakWorkingSet64 = process.PeakWorkingSet64,
                                     VirtualMemorySize64 = process.VirtualMemorySize64,
                                     PerformanceCounters = performanceCounterHistory
                                 };

            return _heartbeatTransform.Value(heartbeatEvent);
        }