Ditched app.metrics

This commit is contained in:
2020-05-24 21:51:03 +00:00
parent f0153eaa0f
commit c2f6fd94c1
12 changed files with 404 additions and 499 deletions

View File

@@ -1,54 +1,65 @@
using System;
using System.Threading.Tasks;
using App.Metrics;
using AyaNova.Util;
using System.Linq;
// using System;
// using System.Threading.Tasks;
// using App.Metrics;
// using AyaNova.Util;
// using System.Linq;
namespace AyaNova.Biz
{
// namespace AyaNova.Biz
// {
/// <summary>
/// called by Generator to flush metrics to reporter
///
/// </summary>
internal static class CoreJobMetricsReport
{
private static TimeSpan DO_EVERY_INTERVAL = new TimeSpan(0, 0, 20);//FLUSH EVERY 20 SECONDS
private static DateTime lastReportFlushDone = DateTime.MinValue;
// /// <summary>
// /// called by Generator to flush metrics to reporter
// ///
// /// </summary>
// internal static class CoreJobMetricsReport
// {
// private static TimeSpan DO_EVERY_INTERVAL = new TimeSpan(0, 0, 20);//FLUSH EVERY 20 SECONDS
// private static DateTime lastReportFlushDone = DateTime.MinValue;
////////////////////////////////////////////////////////////////////////////////////////////////
// DoAsync
//
public static async Task DoJobAsync()
{
//https://www.app-metrics.io/
IMetrics metrics = (IMetrics)ServiceProviderProvider.Provider.GetService(typeof(IMetrics));
//No more quickly than doeveryinterval
if (!DateUtil.IsAfterDuration(lastReportFlushDone, DO_EVERY_INTERVAL))
return;
//RUN ALL REPORTS - FLUSH STATS
var mr = (IMetricsRoot)metrics;
Task.WaitAll(mr.ReportRunner.RunAllAsync().ToArray());
// ////////////////////////////////////////////////////////////////////////////////////////////////
// // DoAsync
// //
// public static async Task DoJobAsync()
// {
// //https://www.app-metrics.io/
// IMetrics metrics = (IMetrics)ServiceProviderProvider.Provider.GetService(typeof(IMetrics));
lastReportFlushDone = DateTime.UtcNow;
// //No more quickly than doeveryinterval
// if (!DateUtil.IsAfterDuration(lastReportFlushDone, DO_EVERY_INTERVAL))
// return;
//just to hide compiler warning for now
await Task.CompletedTask;
// //RUN ALL REPORTS - FLUSH STATS
// var mr = (IMetricsRoot)metrics;
// //Task.WaitAll(mr.ReportRunner.RunAllAsync().ToArray());
// await Task.WhenAll(mr.ReportRunner.RunAllAsync());
}
// lastReportFlushDone = DateTime.UtcNow;
// //just to hide compiler warning for now
// // await Task.CompletedTask;
// // var scheduler = new AppMetricsTaskScheduler(
// // TimeSpan.FromSeconds(3),
// // async () =>
// // {
// // await Task.WhenAll(metrics.ReportRunner.RunAllAsync());
// // });
// // scheduler.Start();
// }
/////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////
}//eoc
// }//eoc
}//eons
// }//eons