我有一些将遥测发送到 Application Insights 的 powershell 代码。我们发现,尽管代码没有变化,但遥测停止到达AI。没有错误。
代码使用以下Powershell函数来创建遥测客户端。
function New-TelemetryClient([Parameter(Mandatory)]$InstrumentationKey, $SessionKey)
{
$MicrosoftApplicationInsightsDll = Get-LibraryFromNuGet Microsoft.ApplicationInsights net46 2.11.0
Add-Type -Path $MicrosoftApplicationInsightsDll.FullName
$tc = New-Object Microsoft.ApplicationInsights.TelemetryClient
$tc.Context.InstrumentationKey = $InstrumentationKey
if (!$SessionKey)
{
$SessionKey = [guid]::NewGuid().ToString()
}
$tc.Context.Session.Id = $SessionKey
$tc
}
我们创建了一个遥测客户端对象,并调用了一系列... TrackEvent
方法来发送自定义事件,然后调用 Flush
. 这段代码在本地机器上工作正常,但在构建机器上却没有发送遥测数据。
奇怪的是,当我们改变Instrumentation Key时,似乎在同一台构建机上也能工作。所以有很多奇怪的事情。
我想获得Application Insights的诊断输出,但我找不到任何关于如何打开它的信息。
所以我的问题是--当从Powershell发送至Application Insights时,我如何收集诊断信息?
有几个选项可以用来排除Application Insights .NET SDK的故障。