Azure Functions 和 Application Insights 请求“操作链接”为空

问题描述 投票:0回答:1

我们将 Azure Functions 升级到独立和 .NET 8。这样做后,我们在 Application Insights 中看到服务总线请求的请求属性“操作链接”基本上为空

Operation links [{"operation_Id":"00000000000000000000000000000000","id":"0000000000000000"}]

这似乎导致在端到端事务视图中多个请求被扔在一起 App Insights showing upstream operation having default guid

Application Insights showing request with operation link having default guids

App Insights showing end to end transaction view - having multiple requests and operation ids which should not be there

在我们的函数中,我们正在配置以下应用程序洞察

program.cs

.ConfigureServices((context, services) =>
{
    services.AddApplicationInsightsTelemetryWorkerService();
    services.ConfigureFunctionsApplicationInsights();
    services.Configure<LoggerFilterOptions>(options =>
    {
        // The Application Insights SDK adds a default logging filter that instructs ILogger to capture only Warning and more severe logs. Application Insights requires an explicit override.
        // Log levels can also be configured using appsettings.json. For more information, see https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service#ilogger-logs
        LoggerFilterRule? ruleToRemove = options.Rules.FirstOrDefault(rule => rule.ProviderName == "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");

        if (ruleToRemove is not null)
        {
            options.Rules.Remove(ruleToRemove);
        }
    });
 }

我希望我只会看到一个对 Azure 服务总线的请求。因为 .NET 6 和进程内就是这种情况

包含编辑

.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enabled</ImplicitUsings>
    <AnalysisLevel>latest-recommended</AnalysisLevel>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Analyzers" Version="1.0.0" />
    <PackageReference Include="Azure.Data.Tables" Version="12.9.1" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.22.1" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.4.0" />
    <PackageReference Include="Microsoft.Azure.NotificationHubs" Version="4.2.0" />
    <PackageReference Include="NetTopologySuite" Version="2.5.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.18.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.22.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
  </ItemGroup>
  <ItemGroup>
    <None Include="local.settings.json" />
  </ItemGroup>
</Project>
azure azure-functions azure-application-insights azureservicebus
1个回答
0
投票

此问题是由发送消息的 API 上较旧的 Application Insights SDK 引起的。

由于进程内功能的模型与孤立功能不同。在日志中深入挖掘,发现每当父 ID 以“|”开头时操作链接竟然被设置为00000...Table view of the log entries

所以只要有“|”在parent id中,该功能完全顶住了操作链接。

更新到 API 上的最新 SDK 可以解决此问题。

© www.soinside.com 2019 - 2024. All rights reserved.