How do I get Timeline data from Glimpse for reporting?

99封情书 提交于 2019-12-10 17:39:21

问题


I am using Glimpse with MVC4, I would like to capture timeline tab data of Glimpse and store it in a DB or File for reporting purposes.


回答1:


There are several ways to do this, but I'll provide you with the answer that gives you the highest level of granularity, which has also been covered on Scott Hanselman's blog.

Hanselman shows how to create the following IInspector implementation:

using Glimpse.Core.Extensibility;
using Glimpse.Core.Message;

public class TimelineTracer : IInspector
{
    public void Setup(IInspectorContext context) {
        context.MessageBroker.Subscribe<ITimelineMessage>(TraceMessage);
    }

    private void TraceMessage(ITimelineMessage message) {
        var output = string.Format(
            "{0} - {1} ms from beginning of request. Took {2} ms to execute.",
            message.EventName,
            message.Offset.Milliseconds,
            message.Duration.Milliseconds);

        System.Diagnostics.Trace.TraceInformation(output, message.EventCategory.Name);
    }
}

If you add this class to your solution, it will be auto-discovered by Glimpse and the TraceMessage method will be called every time a record is added to the Glimpse Timeline.

Scott simply traces that information out, to be seen in the Azure Streaming Diagnostics service. You could instead save the data to a database (or something) to do the analysis you'd like later.



来源:https://stackoverflow.com/questions/25926334/how-do-i-get-timeline-data-from-glimpse-for-reporting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!