private async Task Run() { // while (_isRunning) // { Parallel.ForEach(MetricTasks.ToArray(), task => { task.Run(); }); var healthStatus = await Health.HealthCheckRunner.ReadAsync(_threadCancellationToken); using (var ms = new MemoryStream()) { await Health.DefaultOutputHealthFormatter.WriteAsync(ms, healthStatus); } await Task.WhenAll(Metrics.ReportRunner.RunAllAsync(_threadCancellationToken)); // } }
public override void Enabled(Alex.Alex alex) { if (_isRunning) { return; } _isRunning = true; ConfigureTasks(alex); foreach (var task in MetricTasks.ToArray()) { task.Configure(Metrics); } _threadCancellationTokenSource = new CancellationTokenSource(); _metricTimer = new Timer(async state => await Run(), null, 0, 1000); Log.Info($"Metrics plugin enabled!"); }