没有TelemetryClient.Flush()是否会影响内存或导致性能下降 [英] Is there memory impact or performance cause without TelemetryClient.Flush()

查看:178
本文介绍了没有TelemetryClient.Flush()是否会影响内存或导致性能下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using telemetry client to log custom event log as follow:

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

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

My question is: do we need to flush the client using telemetryClient.Flush() or is it not required?

即使不冲洗,它也可以工作,并且我们能够看到日志.

Even when not flushing it also works and we are able to see the log.

推荐答案

通常,如果您不知道应用程序已关闭的时间,则无需调用flush() . flush实际上是将所有数据推送到应用洞察中(背景).

Usually, you don't need to call flush() if you not aware of the point in which the application is shut down. The flush is really pushing all the data into app insights (background).

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

But let say if you know the point in which the application is shut down then you can call the flush manually to make sure all the data sent properly(without keeping anything in the buffer)

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

Typically if you call the flush it will send the data immediately without keeping in the buffer

请参阅此

这篇关于没有TelemetryClient.Flush()是否会影响内存或导致性能下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆