コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public static void ReportRunning(this ILog logger, IReportMetrics reportMetrics)
 {
     logger.Trace($"Running {reportMetrics.GetType()}");
 }
コード例 #4
0
 public static void ReportFailed(this ILog logger, IReportMetrics reporter)
 {
     logger.Error($"{reporter.GetType()} failed during execution");
 }