C#应用程序洞察失败:TrackEvent不会发送到Azure应用程序洞察 [英] C# Application Insight Failure: TrackEvent Does not send to Azure Application Insight

查看:63
本文介绍了C#应用程序洞察失败:TrackEvent不会发送到Azure应用程序洞察的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Azure Application Insight完全陌生,并尝试通过本地计算机发送TrackEvent.但是Azure Application Insight似乎什么也没收到.

I am completely new to Azure Application Insight and trying to send TrackEvent from via my Local Computer. But Azure Application Insight does not seem to receive anything.

这是我的必需品.规格我的示例asp.net框架控制台代码中安装了应用程序见解sdk nuget,是通过配置Telemetry客户端和Instrumental Id来设置的.控制台运行后,Azure应用程序见解应按预期显示历史记录.但是它什么也没显示.我想念什么吗?

Here is my required. Spec. My sample asp.net framework console code with application insight sdk nuget installed is setup with Telemetry client and Instrumental Id configured. After console runs, Azure application insight should show a history as intended. But itsnot showing anything. Am I missing something?

我的简单控制台代码

Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = "c453fec7-ea68-4c06-83e4-2938eef1f124";
        TelemetryClient telemetry = new TelemetryClient();
        telemetry.Context.User.Id = "Test User Id.";
        telemetry.Context.User.Id = "Test Device Id.";
        telemetry.TrackEvent("Test TrackEvent");

InstrumentationKey是正确的.Telemetry.TractEvent方法不会公开异常.Azure Application Insight搜索(用于自定义事件)不显示历史记录.

InstrumentationKey is correct. Telemetry.TractEvent method does not expose exception. Azure Application Insight Search(for custom event) does not show history.

谢谢.

推荐答案

原因可能是由于以下原因之一:

The cause maybe due to one of the following:

  1. 对于.net控制台应用程序,在门户中创建Application Insights时,应为应用程序类型"选择常规".请参考下面的屏幕截图.

2.在控制台代码中,应添加Flush()和sleep()方法.

2.In your console code, you should add Flush() and sleep() method.

        static void Main(string[] args)
        {
            TelemetryConfiguration.Active.InstrumentationKey = "your key";
            var telemetryClient = new TelemetryClient();
            telemetryClient.Context.User.Id = "uid1";
            telemetryClient.Context.Device.Id = "did1";
            telemetryClient.TrackEvent("AtestEvent7");
            telemetryClient.Flush();

            System.Threading.Thread.Sleep(5000);
        }

然后等待一会儿,我可以在门户网站中看到自定义事件:

Then wait for a while, I can see the custom event in portal:

顺便说一句,我注意到您在代码中两次定义了 telemetry.Context.User.Id ,也许是错字.

BTW, I noticed that you define telemetry.Context.User.Id twice in your code, maybe a typo.

这篇关于C#应用程序洞察失败:TrackEvent不会发送到Azure应用程序洞察的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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