How do I get Timeline data from Glimpse for reporting?

I am using Glimpse with MVC4, I would like to grab the Glimpse timeline tab data and save it to a DB or file for reporting purposes.

+3


source to share


1 answer


There are several ways to do this, but I'll give you the answer that will give you the highest level of detail, which was also included on Scott Hanselman's blog .

Hanselman shows how to create the following implementation IInspector

:

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 automatically detected by Glimpse and the method TraceMessage

will be called every time a record is added to the Glimpse timeline.

Scott is simply tracking this information, which will show up in the Azure Streaming Diagnostics service. Instead, you can save the data to a database (or whatever) to perform the analysis you need later.

+4


source







All Articles