microsoft / microsoft/aspire

Azure Functions - OpenTelemetry host.json log filtering and excessive log noise from host

Open
#10,225 14 comments 3 reactions 0 assignees View on GitHub
area-integrations azure-functions
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

This is related to https://github.com/dotnet/aspire/issues/7901 and https://github.com/dotnet/aspire/issues/7586, both of which have been unfortunately closed.

However, the fix for excessive logging noise was apparently due in Functions Runtime 4.1038, and the problem persists:

![Image](https://github.com/user-attachments/assets/5e7f5ad8-1c9e-4ed3-8f67-b176fdde17c9)

There also appears to be a deeper configuration restriction that I just can't get my head around with the functions host and otel in general, related more to https://github.com/dotnet/aspire/issues/7901. I know that was closed, and this might be more of a question for functions/otel rather than aspire, but I thought I'd start here in case anyone has been able to solve it. Let's say I wanted to filter the logging coming out of the functions host....

Versions:

Visual Studio 2022 17.14.7 Preview 1.0
Functions Runtime 4.1038.300.25164
Aspire 9.3.1
Aspire.Hosting.Azure.Functions 9.3.1-preview.1.25305.6

Steps:

1. Create a new Aspire Starter App.
2. Add a function app to the solution with http trigger, include in aspire orchestration.
3. See the structured logging in the dashboard.
4. Attempt to set the minimum log level in host.json using usual OpenTelemetry approaches (this works with webapi apps):

```
"telemetryMode": "openTelemetry",
"logging": {
"OpenTelemetry": {
"logLevel": {
"default": "Warning",
"Host": "Warning",
"Function": "Warning",
"Host.Aggregator": "Warning"
}
},
```

5. Structured logging below level "warning" still appears in the dashboard. Logging provider alias "OpenTelemetry" configuration seems to be ignored by the function host.
6. Attempt to set the minimum log level using top-level function host approaches:

```
"telemetryMode": "openTelemetry",
"logging": {
"logLevel": {
"default": "Warning",
"Host": "Warning",
"Function": "Warning",
"Host.Aggregator": "Warning"
},
"OpenTelemetry": {
"logLevel": {
"default": "Warning",
"Host": "Warning",
"Function": "Warning",
"Host.Aggregator": "Warning"
}
}
}
```

7. Structured logging still appears in dashboard.

Logging in function apps always seems to be odd in comparison to standard webapi apps. I've tried a lot of variations on this theme. Note that the top-level function logging configuration does impact the logging that appears in the Console. But I've yet to find any way of filtering any otel logging coming out of the host.

I can provide a sample repo if needed.

Many thanks.

### Expected Behavior

Filter the opentelemetry structured logging coming out of the functions host by some means.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version info

.NET SDK:
Version: 9.0.301
Commit: a596cd22e2
Workload version: 9.0.300-manifests.e42facbb
MSBuild version: 17.14.5+edd3bbf37

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.