是否可以使用ASP .NET Core应用程序向AppInsights添加性能监视器指标?

问题描述:

我们正在运行一个ASP .NET核心应用程序,并将其配置为将遥测发送到AppInsights。我还希望在支持AppInsights中的应用程序的服务器上收集perf mon计数器,如内存和CPU使用率。这可能吗?我有在AppInsights中使用我们的标准.NET应用程序配置的perf mon计数器,但无法看到如何使用.NET Core配置它。如果它编译成一个纯粹的是否可以使用ASP .NET Core应用程序向AppInsights添加性能监视器指标?

Type perfModuleType = typeof(PerformanceCollectorModule); 

PerformanceCollectorModule perfModule = (PerformanceCollectorModule)server.ApplicationServices.GetServices<ITelemetryModule>() 
.FirstOrDefault(m => m.GetType() == perfModuleType); 

perfModule.Counters.Add(
     new PerformanceCounterCollectionRequest(
      @"\.NET CLR Memory(??APP_CLR_PROC??)\# GC Handles", "GC Handles")); 

如果ASP.NET应用程序的核心是根据完整的框架NET 4.5.1(及以上)编译,那么它应该在代码中添加计数器一样是可能的netcoreapp目前不支持。