我已经在博客https://azure.microsoft.com/en-us/documentation/articles/app-insights-windows-desktop/之后使用AI创建了一个基本的控制台应用程序,但是在我的Azure帐户的AI中没有捕获任何指标。也没有报告任何错误/异常。我在这里错过了什么吗?下面是代码。有一些文档说HockeyApp是捕获通过应用商店提供的Windows应用程序指标的新方法,但是没有足够的信息用于控制台或Windows服务。你能分享一下你的经历吗?
using System;
using Microsoft.ApplicationInsights;
namespace Logger
{
class Program
{
static void Main(string[] args)
{
TelemetryClient tc = new TelemetryClient();
tc.Context.User.Id = Environment.UserName;
tc.Context.Session.Id = Guid.NewGuid().ToString();
tc.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
tc.TrackPageView("Form1");
tc.Flush();
System.Threading.Thread.Sleep(1000);
}
}
}
ApplicationInsights.config
<applicationinsights xmlns="http://schemas.microsoft.com/A...">
<instrumentationkey>
mykey
</instrumentationkey>
<telemetrychannel type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<telemetryprocessors>
<add type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<maxtelemetryitemspersecond>5</maxtelemetryitemspersecond>
</add>
</telemetryprocessors>
<telemetryinitializers>
<add type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<add type="Microsoft.ApplicationInsights.WindowsServer.DomainNameRoleInstanceTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<add type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
</telemetryinitializers>
<telemetrymodules>
<add type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
<add type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<add type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
</telemetrymodules>
<severity>Verbose</severity>
</applicationinsights>
答案 0 :(得分:0)
It appears the issue was with the Operating System (Windows 10 Pro). Upon copying it to Windows Server 2012 server, logs were appearing in AI. No clues as why it wasn't working in Windows 10 Pro. I have used LINQPad as suggested here and observed all traces were sent to AI properly but they were still not getting displayed in AI.
答案 1 :(得分:0)
您需要在_ = TelemetryConfiguration.Active;
方法的第一行添加Main
:
static void Main(string[] args)
{
_ = TelemetryConfiguration.Active;
var configuration = TelemetryConfiguration.CreateDefault();
configuration.InstrumentationKey = "{Your Ai Instrumentation Key}";
var tc = new TelemetryClient(configuration);
tc.TrackTrace("Test");
tc.Flush();
}