2011-11-22 47 views
2

我正在使用MiniProfiler來剖析我的MVC應用程序和WCF服務,這就像一個魅力與一個警告 - 當配置文件信息包含sql。MiniProfiler無法顯示SqlTimings

症狀:

  1. 的「查詢時間(毫秒)」標題從彈出
  2. 的「%在SQL」也從彈出
  3. 底部失蹤失蹤如果我點擊在「SQL」鏈接則顯示灰色的疊加,但沒有任何信息,並引發了一些jQuery的錯誤(它無法找到元素)。

小挖後,我發現,這是所有做的JSON響應HasSqlTimings沒有在JSON響應的根HasSqlTimings(假),這是根的信息/之間的不一致兒童等級(真)。

[OnDeserialized] 
void OnDeserialized(StreamingContext ctx) 
{ 
    HasSqlTimings = GetTimingHierarchy().Any(t => t.HasSqlTimings); 
    HasDuplicateSqlTimings = GetTimingHierarchy().Any(t => t.HasDuplicateSqlTimings); 

    if (_root != null) 
    { 
     _root.RebuildParentTimings(); 
    } 
} 

我看了看源代碼,它看起來應該可以正常工作但沒有處理!有沒有人有任何想法,我可能會出錯?

回答

0

我實現這個時候有同樣的問題。當UI層不進行任何SQL調用,但隨後使用SQL調用返回WCF數據時,會發生此問題。根時序不知道層次結構中存在以下SQL時序。

我添加了一行,以便在添加「遠程」時序時,我們設置「hasSqlTimings」字段,以便UI知道如何正確渲染框。下面是我在MvcMiniProfiler \ MiniProfiler.cs修改了代碼:

/// <summary> 
/// Adds <paramref name="externalProfiler"/>'s <see cref="Timing"/> hierarchy to this profiler's current Timing step, 
/// allowing other threads, remote calls, etc. to be profiled and joined into this profiling session. 
/// </summary> 
public static void AddProfilerResults(this MiniProfiler profiler, MiniProfiler externalProfiler) 
{ 
    if (profiler == null || externalProfiler == null) return; 
    profiler.Head.AddChild(externalProfiler.Root); 
    profiler.HasSqlTimings = profiler.GetTimingHierarchy().Any(t => t.HasSqlTimings); 
} 
+0

我提交了錯誤此:http://code.google.com/p/mvc-mini-profiler/issues/detail? ID = 124&感謝= 124&amp; TS = 1321969953 –