public override DynamicJsonValue ToJson() { var recent = GetRecentMetrics(); var history = GetSummerizedItems(); var stats = new PerformanceMetricsStats(Type); foreach (var meter in recent) { var recentStats = new TransactionPerformanceMetricsRecentStats { Start = meter.Start.GetDefaultRavenFormat(), Counter = meter.Counter, CommandsCounter = meter.CommandsCounter, Duration = Math.Round(meter.Duration.TotalMilliseconds, 2), InternalWindows = new List <InternalWindowDuration>(), Type = Type }; var cur = meter.InternalDurations; while (cur != null) { recentStats.InternalWindows.Add(cur); cur = cur.Prev; } recentStats.InternalWindows.Reverse(); stats.Recent.Add(recentStats); } AddHistoryStats(history, stats); return(stats.ToJson()); }
protected void AddHistoryStats(IEnumerable <SummerizedItem> history, PerformanceMetricsStats stats) { foreach (var meter in history) { var historyStats = new PerformanceMetricsHistoryStats { Start = meter.TotalTimeStart.GetDefaultRavenFormat(isUtc: true), End = meter.TotalTimeEnd.GetDefaultRavenFormat(isUtc: true), Counter = meter.TotalCounter, Duration = Math.Round((meter.TotalTimeEnd - meter.TotalTimeStart).TotalMilliseconds, 2), ActiveDuration = Math.Round(meter.TotalTime.TotalMilliseconds, 2), MaxDuration = Math.Round(meter.MaxTime.TotalMilliseconds, 2), MinDuration = Math.Round(meter.MinTime.TotalMilliseconds, 2), Type = Type }; stats.History.Add(historyStats); } }
public override DynamicJsonValue ToJson() { var recent = GetRecentMetrics(); var history = GetSummerizedItems(); var stats = new PerformanceMetricsStats(Type); foreach (var meter in recent) { var recentStats = new PerformanceMetricsRecentStats { Start = meter.Start.GetDefaultRavenFormat(isUtc: true), Counter = meter.Counter, Duration = Math.Round(meter.Duration.TotalMilliseconds, 2), Type = Type }; stats.Recent.Add(recentStats); } AddHistoryStats(history, stats); return(stats.ToJson()); }