我正在将应用程序洞察 SDK 用于 wpf 应用程序,我一直致力于捕获一些简单的遥测数据。我正在加载如下所示的配置文件
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<ExcludedTypes>Event</ExcludedTypes>
</Add>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<IncludedTypes>Event</IncludedTypes>
</Add>
</TelemetryProcessors>
问题是当我运行已安装的应用程序并且离线时,遥测数据可以正常捕获。下次我在线打开应用程序时,数据最终会被推送到应用程序洞察中。但是,当其他人离线运行应用程序时,当他们重新上线时,他们的数据永远不会被推送到应用程序洞察中。
这里的配置方式有问题吗?为什么这对某些用户有效,但对其他用户无效?
编辑:今天与用户一起工作时,我注意到当他们离线并运行应用程序时,没有保存临时文件。当我在计算机上执行相同的操作时,我注意到创建了一个奇怪的临时文件。当我重新上线运行该应用程序时,它就消失了。
最佳答案
在用户计算机上进行调试并深入研究代码后,我发现服务器遥测 channel 使用此函数 NetworkInterface.GetIsNetworkAvailable();
它始终为我的用户返回 true,即使他们离线是因为它们有一些额外的网络适配器认为它们连接到未知网络。
关于c# - 离线时 App Insights 遥测不发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50183122/