调试模式下,ApplicationInsights TelemetryClient 初始化非常缓慢

6
我遇到了一个关于Microsoft.ApplicationInsights对象的问题。每次代码第一次访问这些对象时,初始化时间非常长(有时甚至达到40秒左右)。
示例1: First initialization of TelemetryClient 示例2: DisableTelemtry 这是什么原因导致了这么长的首次加载时间?我该如何解决这个问题?
1个回答

6
为什么不在debug模式下使用web.config变换来禁用ApplicationInsight呢?
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
      <httpModules>
        <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="ApplicationInsightsWebTracking" />
      </httpModules>
  </system.web>
  <system.webServer>
    <modules>
      <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="ApplicationInsightsWebTracking"  />
    </modules>
  </system.webServer>
</configuration>

我曾经遇到过类似的问题,这个问题的答案向我解释了如何在我的开发环境中使用这段代码片段(即不在发布流程中使用)。


2
谢谢,我刚刚禁用了它 - 我的应用程序启动速度更快了。 - SteppingRazor
我怀疑在正常的调试过程中是否会触发转换?! - Falco Alexander
@FalcoAlexander - 试一下...它有效。 - Leo
我尝试过了,但仍然会触发 Insight 事件。尽管我不得不添加以下内容:<system.webServer> <modules> <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="TelemetryCorrelationHttpModule" /> </modules> </system.webServer> - Falco Alexander
还必须添加 <system.diagnostics> <trace> <listeners> <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="myAppInsightsListener" /> </listeners> </trace> </system.diagnostics>...现在很安静 :) @LeonardoSeccia,你的答案是否考虑加入这个? - Falco Alexander

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接