【问题标题】:Is there memory impact or performance cause without TelemetryClient.Flush()没有 TelemetryClient.Flush() 是否存在内存影响或性能原因
【发布时间】:2019-02-05 12:37:06
【问题描述】:

使用遥测客户端记录自定义事件日志如下:

  var telemetryClient = new TelemetryClient();
  telemetryClient.InstrumentationKey = "<your actual insight instrumentkey>";    
  telemetryClient.TrackRequest(req.RequestUri.ToString(), DateTime.Now, Stopwatch.StartNew().Elapsed, "200", true);

我的问题是:我们需要使用telemetryClient.Flush() 刷新客户端还是不需要?

即使不刷新它也可以工作,我们可以看到日志。

【问题讨论】:

    标签: c# azure azure-functions azure-application-insights telemetry


    【解决方案1】:

    通常,如果您不知道应用程序关闭的时间点,则无需致电flush()flush 真正将所有数据推入应用洞察(背景)。

    但是,如果您知道应用程序关闭的时间点,那么您可以手动调用flush 以确保所有数据都正确发送(而不在缓冲区中保留任何内容)

    通常,如果您调用flush,它将立即发送数据而不保留在缓冲区中

    Refer this SO

    【讨论】:

    • 感谢您的评论并分享所附链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 2019-03-22
    • 2016-09-07
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    相关资源
    最近更新 更多