How to disable standard performance counters in Application Insights?(如何在应用程序洞察中禁用标准性能计数器?)
问题描述
Application Insights中的标准性能计数器生成的数据量太大。我如何禁用它们并只报告我自己的计数器+一些标准计数器(但不是全部),或者只是降低采样频率?
推荐答案
为asp.netcore用户添加此答案。如下所示修改启动.cs。你有两个选择。首先完全禁用性能计数器。
public void ConfigureServices(IServiceCollection services)
{
var serviceDescriptor = services.FirstOrDefault(descriptor => descriptor.ImplementationType == typeof(PerformanceCollectorModule));
services.Remove(serviceDescriptor);
}
或Second删除单个计数器,如果以后需要,您可以添加自己的计数器。
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var modules = app.ApplicationServices.GetServices<ITelemetryModule>();
var perfModule = modules.OfType<PerformanceCollectorModule>().First();
perfModule.DefaultCounters.Clear();
}
这篇关于如何在应用程序洞察中禁用标准性能计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!