【发布时间】:2019-01-27 23:32:20
【问题描述】:
对于 Azure App Insights 中的 Flush() 方法,我想知道它是否会影响项目的性能?
我尝试删除 Flush() 并且所有自定义数据仍然发送到 App Insights。所以我的问题应该是为什么我们需要 Flush()?我们可以删除它吗?
【问题讨论】:
标签: azure azure-application-insights telemetry
对于 Azure App Insights 中的 Flush() 方法,我想知道它是否会影响项目的性能?
我尝试删除 Flush() 并且所有自定义数据仍然发送到 App Insights。所以我的问题应该是为什么我们需要 Flush()?我们可以删除它吗?
【问题讨论】:
标签: azure azure-application-insights telemetry
TelemetryClient 上的Flush() 将它当前在缓冲区中的所有数据推送到 App Insights 服务。
您可以在此处查看其源代码:https://github.com/Microsoft/ApplicationInsights-dotnet/blob/3115fe1cc866a15d09e9b5f1f7f596385406433d/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L593。
通常,Application Insights 会在后台批量发送您的数据,以便更有效地使用网络。 如果您启用了开发者模式或手动调用 Flush(),则会立即发送数据。
通常您不需要调用 Flush()。 但如果您知道该进程将在该点之后退出,您将需要调用 Flush() 以确保所有数据都已发送。
【讨论】: