azure - 使用 Azure 应用程序见解托管在 Azure Functions 上的 Asp.net core - 如何禁用性能计数器收集

标签 azure asp.net-core azure-functions azure-application-insights

我有一个 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);
}

我仍然能够在日志分析中看到性能计数器。

enter image description here

最佳答案

有一个设置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/

相关文章:

c# - Azure.Messaging.EventHubs 与 WindowsAzure.ServiceBus 生成的消息有区别吗?

node.js - 将数千条消息添加到 Azure 存储队列

Azure.Cosmos 或 Microsoft.Azure.Cosmos、Azure.Storage.Blob 或 Microsoft.Azure.Storage.Blob?适用于.NET Core 3.1

c# - Azure KeyVault 配置提供程序在更改时重新加载值

c# - 授权策略的依赖注入(inject)

c# - 在Azure功能中使用appsettings

azure - 在 Azure 函数中运行 Selenium

azure - 根据 Azure ML Studio 中的条件替换列中的值

node.js - Azure无服务器函数: input binding DataType "stream" not supported

azure - 仅在应用服务 Azure 上传出数据