关闭应用程序见解的抽样

时间:2018-03-19 13:22:48

标签: azure azure-web-sites azure-application-insights

我正在使用网络应用程序和Visual Studio 2015的应用程序见解的最新版本,我试图关闭应用程序见解的抽样,但它仍然在 我删除了以下内容:

<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
  <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
  <IncludedTypes>Event</IncludedTypes>
</Add>

我添加了下面的

   <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
  <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
  <ExcludedTypes>Event;PageView;Request</ExcludedTypes>
</Add>

我甚至试图删除ExcludedTypes的所有部分,我也尝试了下面的内容

   <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
  <ExcludedTypes>Event;PageView;Request</ExcludedTypes>
</Add>

但以上所有内容都不起作用我继续得到以下

enter image description here

1 个答案:

答案 0 :(得分:2)

正如ZakiMa所说,您可以尝试删除或注释掉AdaptiveSamplingTelemetryProcessor节点。请参阅此article

  

禁用自适应采样:在ApplicationInsights.config中,删除或注释掉AdaptiveSamplingTelemetryProcessor节点。

<TelemetryProcessors>

<!-- Disabled adaptive sampling:
  <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
    <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
  </Add>
-->

如果您的项目是.Net Core项目,则可以通过代码禁用自适应采样。请参阅此article

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            var tc = TelemetryConfiguration.Active;
            var channel = tc.TelemetryChannel;

            var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions();
            aiOptions.EnableAdaptiveSampling = false;
            aiOptions.InstrumentationKey = "myikey";

            services.AddApplicationInsightsTelemetry(aiOptions);                        
        }