首页 文章

启用Application Insights会使Web应用程序挂起

提问于
浏览
6

在我的Web项目上启用Application Insights后,它可以运行几个请求,但随后所有请求都会无限期挂起 . 这是使用Visual Studio调试器在本地运行的 . 使用fiddler,我可以看到请求正在等待响应,这种情况永远不会发生 . 没有错误 . 最终Visual Studio也挂了,我需要杀掉它 .

我正在使用Visual Studio 2013更新4.我右键单击了我的Web项目,然后单击Add Application Insights Telemetry . 接下来,我从ApplicationInsights.config中删除了Instrumentation Key,因为我不希望遥测用于本地开发 . Instrumentation Key将在实时应用程序的Azure App Settings中设置 .

如果我在没有Application Insights的情况下退回,我就不会挂起 .

有任何想法吗 ?谢谢!

3 回答

  • 2

    我运行2.0.0-rc1并遇到了这个问题 . 在ApplicationInsights.config中注释这行代码也解决了这个问题 .

    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
    

    将Application Insights升级到2.0.0也为我解决了这个问题 . 谢谢Anastasia&Allen!

  • 3

    [ EDIT ]

    之前的修复似乎首先起作用,但真正的诀窍是从ApplicationInsights.config注释掉PerformanceCollectorModule .

    <TelemetryModules>
        ...
        <!--
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
        -->
        ...
    </TelemetryModules>
    

    [ Old Answer ]

    如果没有提供仪器密钥,则禁用遥测确实可以解决问题 .

    我有点期待这是在引擎盖下完成的,但似乎没有 .

    我将此代码放在global.asax Application_Start方法中:

    if (string.IsNullOrEmpty(WebConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"]))
    {
        Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.DisableTelemetry = true;
    }
    
  • 1

    我不想从另一个答案中窃取任何信用,但我想详细说明我的评论 . 我重新安装了Visual Studio(我知道的远程镜头)并且仍然存在问题 . 似乎当用于AI的HTTP模块加载到IIS Express中时,事情会快速向南移动,因此我不得不求助于在运行发布配置时仅加载这些模块 .

    这意味着更新web.config以删除AI语句,而是将它们移动到Web.Release.config作为转换,以便在构建发布配置时加载它们:

    https://stackoverflow.com/a/27923364/571237

    但请注意,自该答案发布以来,程序集已更改 . 这是我需要添加的内容:

    <system.web>
        <compilation xdt:Transform="RemoveAttributes(debug)" />
        <httpModules>
          <!-- Enable application insights when running in release mode (it don't work right locally...) -->
          <!-- https://stackoverflow.com/a/27923364/571237 -->
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
               xdt:Transform="Insert"/>
        </httpModules>
      </system.web>
    
      <system.webServer>
        <modules>
          <!-- Enable application insights when running in release mode (it don't work right locally...) -->
          <!-- https://stackoverflow.com/a/27923364/571237 -->
          <remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert"/>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" xdt:Transform="Insert" />
        </modules>
      </system.webServer>
    

相关问题