c# - 离线时 App Insights 遥测不发送

标签 c# wpf azure azure-application-insights telemetry

我正在将应用程序洞察 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/

相关文章:

Azure 数据工厂事件副本从 foreach 事件获取多个表名称

单击“保存”按钮后的 WPF 数据绑定(bind)

c# - Resharper 在 if 语句旁边移动顶部大括号。怎么上新线?

c# - 如何在c#中的文本框之间复制选定的日期

java - 有效地在不同的虚拟机之间复制对象

c# - 带有确定和取消按钮的弹出子窗口

.net - WPF - 将列表框绑定(bind)到列表 <string> - 我做错了什么?

azure - 仅授权特定用户使用 azure webapp

sql - 从 Node.JS 连接到 SQL Azure

c# - 所有 Process* 方法和所有消息过滤器的目的是什么?