我有一个 Azure 函数,它是使用 Asp.net core 2.2 实现的,该函数使用 Windows 消耗计划。我还使用 Microsoft.ApplicationInsights.AspNetCore 包。我正在尝试禁用性能计数器收集,但到目前为止还没有成功。有没有办法禁用性能计数器收集?
我用来删除性能计数器模块的代码是
public override void Configure(IFunctionsHostBuilder builder)
{
var serviceDescriptor = builder.Services.FirstOrDefault(descriptor => descriptor.ImplementationType == typeof(PerformanceCollectorModule));
builder.Services.Remove(serviceDescriptor);
}
我仍然能够在日志分析中看到性能计数器。
最佳答案
有一个设置EnablePerformanceCountersCollection
可用于关闭性能计数器收集。 (https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLoggerOptions.cs#L88)
这将位于 applicationinsights 下的 host.json
{
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond" : 5
},
"EnablePerformanceCountersCollection" : false
}
}
关于azure - 使用 Azure 应用程序见解托管在 Azure Functions 上的 Asp.net core - 如何禁用性能计数器收集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58130193/