public static void ReportRan(this ILog logger, IReportMetrics reportMetricsReporter, long startTimestamp) { if (startTimestamp == 0) { return; } var currentTimestamp = Stopwatch.GetTimestamp(); var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); logger.Info("Report {ReportType} ran in {ElapsedMilliseconds}ms", reportMetricsReporter.GetType().FullName, elapsed.Milliseconds); }
private async Task FlushMetrics(IMetrics metrics, CancellationToken cancellationToken, IReportMetrics reporter) { try { Logger.ReportRunning(reporter); var result = await reporter.FlushAsync(metrics.Snapshot.Get(reporter.Filter), cancellationToken); if (result) { metrics.Measure.Counter.Increment(_successCounter, reporter.GetType().FullName); } else { metrics.Measure.Counter.Increment(_failedCounter, reporter.GetType().FullName); Logger.ReportFailed(reporter); } } catch (Exception ex) { metrics.Measure.Counter.Increment(_failedCounter, reporter.GetType().FullName); Logger.ReportFailed(reporter, ex); } }
public static void ReportRunning(this ILog logger, IReportMetrics reportMetrics) { logger.Trace($"Running {reportMetrics.GetType()}"); }
public static void ReportFailed(this ILog logger, IReportMetrics reporter) { logger.Error($"{reporter.GetType()} failed during execution"); }