【问题标题】:Azure Functions v3 no longer auto-tracking dependencies after adding injected TelemetryConfiguration添加注入的 TelemetryConfiguration 后,Azure Functions v3 不再自动跟踪依赖项
【发布时间】:2022-01-14 20:40:06
【问题描述】:

目前在 .netcore 3.1 中有一个天蓝色函数 v3,带有以下 host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false,
        "excludedTypes": "Exception"
      },
      "dependencyTrackingOptions": {
        "enableSqlCommandTextInstrumentation": true
      }
    },
    "logLevel": {
      "Function": "Information",
      "Host.Aggregator": "Information",
      "Host.Results": "Information",
      "default": "Warning"
    }
  }
}

在应用洞察中自动跟踪 SQL 依赖关系时一切正常。还需要跟踪 redis 调用我已按照建议通过依赖注入添加了 telemetryClient

telemetryClient = new TelemetryClient(telemetryConfiguration);

然而,在这样做之后,我只接收到我通过遥测客户端手动编写的依赖调用,而不再获得默认的 SQL 调用。

我尝试手动创建一个 DependencyCollector.DependencyTrackingTelemetryModule 并使用注入的遥测配置和设置对其进行初始化 EnableSqlCommandTextInstrumentation = true ,虽然这确实启用了 SQL 跟踪,但它并没有将它绑定到调用上下文。

之前有没有人遇到过这个问题,或者对如何正确实施自定义遥测同时保持默认依赖跟踪有任何建议?

【问题讨论】:

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


【解决方案1】:

将 Microsoft.Azure.WebJobs.Logging.ApplicationInsights 降级到与 Microsoft.NET.Sdk.Functions 相同的版本,并且可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-28
    • 2022-07-26
    • 2020-12-03
    • 2021-11-05
    • 1970-01-01
    相关资源
    最近更新 更多