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.
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.