【问题标题】:Turn off Application Insights关闭 Application Insights
【发布时间】:2015-08-28 06:38:16
【问题描述】:

我正在开发一个 Web 应用程序,该应用程序发送数以千计的带有应用程序洞察力的请求。

Application Insights 在哪里开启和关闭?

【问题讨论】:

标签: asp.net azure-application-insights


【解决方案1】:

我不知道到底在哪里打开,但我猜你正在寻找一种方法来提供切换应用程序洞察力,并且在你的 Application_Start 中这样做你可以这样做:

TelemetryConfiguration.Active.DisableTelemetry = true;

这样做您将停止发送遥测信息。

希望对您有所帮助,如果没有,请告诉我们您的尝试,以便我更好地理解您的问题。

有关更多信息,您可以查看他们的文档here。关于自定义初始化器的部分也很有趣,也许对你也有帮助。

【讨论】:

  • 我将您建议的行添加到 Global.asax.cs 但在输出窗口中我得到了数千行以 - Application Insights Telemetry : {"ver":1,"name":" 开头的行Microsoft.ApplicationInsights.PerformanceCounter", ....
  • 即使 DisableTelemetry 设置为 true 且检测密钥为空,遥测模块仍将继续收集数据。数据不会发送,但会被收集。请参阅针对 App Insights 记录的此问题:github.com/Microsoft/ApplicationInsights-dotnet/issues/397 如果要禁用首次输出,可以按照github.com/Microsoft/ApplicationInsights-dotnet/issues/310中的步骤操作
【解决方案2】:

简短的回答是,为了使 Application Insights 遥测静音,您需要将 DisableTelemetry 标志设置为 false。

但是,您需要确保在正确的 TelemetryConfiguration 实例上设置标志。因此,如果您使用 TelemetryConfiguration.Active 以外的 TelemetryConfiguration,则需要在该实例上设置标志。 PerformanceCollectorModule 遥测模块使用的 TelemetryConfiguration 实例也可能与您的 TelemetryClient 使用的实例不同。

在我们进一步讨论之前,让我们先澄清几件事:

  1. 您是只在“输出”窗口中看到与 Microsoft.ApplicationInsights.PerformanceCounter 相关的项目,还是还看到其他项目?

  2. 如何配置 Application Insights?您是否使用 ApplicationInsights.config 文件?您是否创建自己的 TelemetryConfiguration 实例和 TelemetryClient 实例?演示初始化过程的代码 sn-p 会很有帮助。

【讨论】:

    【解决方案3】:

    这个问题是关于如何关闭 Application Insights 还是关闭 Application Insights Telemetry?因为上面两个答案都是关于如何关闭遥测的。

    实际上,Azure 门户上的应用程序洞察通过 applicationinsights.config 与您的 Web 应用程序进行通信。如果要禁用它,只需将键值设置为空即可。

    【讨论】:

      【解决方案4】:

      要关闭 Application Insights,请从 Web.config 的 System.WebServer/Modules 部分中删除该模块。

      如果您想完全删除它,您应该卸载 Application Insight NuGet 包,并删除 ApplicationInsights.config。

      【讨论】:

      • 这对我来说适用于旧的 ASP.NET 4.8 项目。
      【解决方案5】:

      我知道我来晚了。但这可能会对遇到此线程的其他人有所帮助。

      我将此解决方案应用于我在 ASP.NET MVC Core 中的项目。

      请注意,这会禁用所有环境(开发、生产、暂存等)的 Application Insights 日志记录

      按照附图中的说明进行操作。更容易理解。

      【讨论】:

        【解决方案6】:

        在创建项目时,有一个添加 AI 的复选框。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-08-14
          • 2019-07-14
          • 2016-05-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-03-15
          相关资源
          最近更新 更多