Azure / Azure/azure-functions-dotnet-worker

.Net 7 Isolated Azure Functions splits logs into multiple Application Insights logs, on line-break

Open
#2,257 0 comments 2 reactions 0 assignees View on GitHub
area: application-insights bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

Hello, as demonstraded in the image below, I'm getting multiple Application Insights trace logs, for a single error. Anyone have an idea of what I might be doing wrong? Can it be connected to the specific problem of the JobHost not being able to start correctly?

In that case, it fails on the following line (line 46) in the program.cs file
`var host = builder.Build();`

![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/47446279/d3b005f5-4ff0-45f4-af8a-0488bdb18906)

### Steps to reproduce

- Runtime: .Net 7 isolated v4 azure function worker,
- Hosted on a Windows App service plan: PremiumV2 P1v2

Packages in the Functions project are:
```csproj












```

I'm registering my logging like this
```csharp
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = new HostBuilder();

builder.ConfigureFunctionsWorkerDefaults(applicationBuilder =>
{
applicationBuilder.Services.AddApplicationInsightsTelemetryWorkerService();
applicationBuilder.Services.ConfigureFunctionsApplicationInsights();
}, workerOptions => { });
```

And then later on I configure an `ITelemetryInitializer`:

```csharp
public static class ConfigureServices
{
public static IServiceCollection AddFunctionAppServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton();

return services;
}
}
```

Where `FunctionAppTelemetryInitializer` looks like this:
```csharp
public class FunctionAppTelemetryInitializer : ITelemetryInitializer
{
private readonly IOptions _applicationOptionsWrapper;

public FunctionAppTelemetryInitializer(IOptions applicationOptionsWrapper)
{
_applicationOptionsWrapper = applicationOptionsWrapper;
}

public void Initialize(ITelemetry telemetry)
{
telemetry.Context.GlobalProperties.TryAdd("ApplicationName", _applicationOptionsWrapper.Value.FunctionAppName);
}
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Program.cs around line 46 and review the package references and logging setup shown in the issue, especially AddApplicationInsightsTelemetryWorkerService, ConfigureFunctionsApplicationInsights, and the custom ITelemetryInitializer. Reproduce the .NET 7 isolated worker failure on the stated hosting plan and verify whether one error is emitted as multiple Application Insights trace logs; done means identifying and documenting the cause or confirming a worker defect.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.