如何从Glimpse获取时间轴数据进行报告? [英] How do I get Timeline data from Glimpse for reporting?

查看:120
本文介绍了如何从Glimpse获取时间轴数据进行报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Glimpse与MVC4结合使用,我想捕获Glimpse的时间轴标签数据并将其存储在数据库或文件中以进行报告.

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.

推荐答案

有几种方法可以做到这一点,但我将为您提供最高粒度的答案,这也是发现在Scott Hanselman的博客中.

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展示了如何创建以下IInspector实现:

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);
    }
}

如果将此类添加到解决方案中,则Glimpse会自动发现该类,并且每次将记录添加到Glimpse时间轴时都会调用TraceMessage方法.

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只是将这些信息追溯出来,以便在Azure流诊断服务中看到.相反,您可以将数据保存到数据库(或其他内容)中,以便稍后进行所需的分析.

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.

这篇关于如何从Glimpse获取时间轴数据进行报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆