MS AI:使用 Persistence Channel 复制事件

MS AI: Duplicate event with Persistence Channel

我们正在将 Application Insights 引入我们的桌面应用程序。由于用户在使用应用程序时可能处于离线状态,我们使用 PersistenceChannel 来确保事件可以在以后的会话中发送,并且我们在应用程序关闭时调用 flush(我们的 Tracker 的 Dispose()) :

public ApplicationInsightsTracker()
{
    this.client = new TelemetryClient();
    this.client.InstrumentationKey = InstrumentationKey;

    TelemetryConfiguration.Active.TelemetryChannel = new PersistenceChannel();
    TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
}

~ApplicationInsightsTracker()
{
    this.Dispose();
}

public override void Dispose()
{
    this.client.Flush();
    GC.SuppressFinalize(this);
}

public override void TrackEvent(ITrackerEvent trackerEvent)
{
    try
    {
        this.client.TrackEvent(trackerEvent.Name, trackerEvent.Properties);
    }
    catch (Exception e)
    {
        Debug.WriteLine(string.Format("Failed to track event {0}.  Exception message {1}", trackerEvent.Name, e.Message));
    }
}

我们还使用连续导出将事件数据从 Application Insights 发送到 Azure Blob 数据库。我们将 Power BI 连接到 Blob 数据库,前几天刷新功能停止工作。我们进行了调查,结果发现我们正在加载 2 个具有相同唯一 ID 的事件。查看 blob,我们发现 2 个连续的 blob 具有相同的事件:

blob1.blob  - Holds 1 event
{"event":...,"internal":{"data":{"id":"8709bb70-e6b1-11e5-9080-f77f0d66d988"..."data":{..."eventTime":"2016-03-10T11:15:53.9378827Z"}..."user":{..."anonId": "346033da-012d-4cc4-9841-836e5d8f8e32"..."session":{"id":"cb668d2f-9755-4afd-97c2-66cc3504349a"...

blob2.blob - Holds 3 events
{"event":...,"internal":{"data":{"id":"8709bb70-e6b1-11e5-9080-f77f0d66d988"..."data":{..."eventTime":"2016-03-10T11:15:53.9378827Z"}..."user":{..."anonId": "346033da-012d-4cc4-9841-836e5d8f8e32"..."session":{"id":"cb668d2f-9755-4afd-97c2-66cc3504349a"...
{"event":...
{"event":...

如您所见,两个 blob 上的第一个事件是相同的。我们在 PersistenceChannel 上进行了 运行 测试,让机器与网络连接/断开连接,并且 AI 做了这件事。

我们不完全确定这是我们使用方式的问题,还是库的缺陷。正如您想象的那样,通过重复事件可能会非常痛苦(特别是如果您在外部构建模型)。

我们是在用 AI 做一些奇怪的事情,还是这是一个已知问题?

我咨询了做出口的团队,他们说

the current export pipeline has opportunities for duplicate exports

这是他们正在研究的事情。

所以看起来您没有做错任何事情,这只是您需要注意的一个案例,并暂时解决。

从 App Insights 导出的数据可能包含重复数据。

如果您要将所有数据导出到 Power BI,那么您可以使用 Power Query's built-in duplicate removal feature