Skip to content

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

Open

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This is related to #7901 and #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

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 #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"
        }
      },
  1. Structured logging below level "warning" still appears in the dashboard. Logging provider alias "OpenTelemetry" configuration seems to be ignored by the function host.
  2. 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"
        }
      }
    }
  1. 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

Activity

  1. added
    needs-area-label
    on Jul 2, 2025
  2. captainsafia commented on Jul 3, 2025

    @captainsafia
    Contributor

    Rohit Ranjan (@RohitRanjanMS) Does anything look off to you about the host version or config the user is using here?

    Andrew Smith (@DGAISmith) Perhaps a quick sample app would help here as well!

  3. added
    area-integrations
    azure-functions
    and removed
    needs-area-label
    on Jul 3, 2025
  4. DGAISmith commented on Jul 3, 2025

    @DGAISmith
    Author

    Many thanks for the comment. I've created a sample repo that tries to show the problems we're having. I've tried to layer the commits to show how things progress:

    https://github.com/DGAISmith/AspireFunctionOtel

    Note that before I add the service bus trigger, I'm unable to filter the otel structured logging coming from the host (although this may be because I simply don't know how to configure the otel behaviour in the host, it's not clear what my options are to be honest and I've tried a lot of different methods).

    After I add the service bus trigger, you then get all the noise in the structured logs. Which of course I'm still unable to filter out due to the above.

  5. RohitRanjanMS commented on Jul 3, 2025

    @RohitRanjanMS

    Thanks for the sample, Andrew Smith (@DGAISmith). I will have a look at it. Meanwhile, can you configure Functions defaults and see if it makes any difference?

    dotnet add package Microsoft.Azure.Functions.Worker.OpenTelemetry --version 1.0.0-preview1

    builder.Services.AddOpenTelemetry().UseFunctionsWorkerDefaults();

  6. DGAISmith commented on Jul 4, 2025

    @DGAISmith
    Author

    Thanks for the sample, @DGAISmith. I will have a look at it. Meanwhile, can you configure Functions defaults and see if it makes any difference?

    dotnet add package Microsoft.Azure.Functions.Worker.OpenTelemetry --version 1.0.0-preview1

    builder.Services.AddOpenTelemetry().UseFunctionsWorkerDefaults();

    If I add this (well, I've used 1.1.0-preview6). in addition to the standard aspire service defaults (should I use it instead of?):

    var builder = FunctionsApplication.CreateBuilder(args);
    
    builder.AddServiceDefaults();
    builder.Services.AddOpenTelemetry().UseFunctionsWorkerDefaults();
    
    builder.ConfigureFunctionsWebApplication();
    
    builder.Build().Run();
    
    

    ...a lot of the noise in structured logging goes away from the service bus activity, and the duplicate logs are sorted. However:

    • the name of the resource changes from "functionservice" (as defined in the aspire apphost) to AspireFunctionOtel.Function (the name of the function app assembly, presumably)
    • I'm still seeing all log levels
    • I'm still seeing a lot of noise in the Traces view

    Image

    Image

  7. DGAISmith commented on Jul 30, 2025

    @DGAISmith
    Author

    I've done more digging around this. I believe one part of the problem is a conflict between the ServiceDefaults code that gets scaffolded in to a new Aspire app and the necessary steps for Otel with Functions. It just doesn't include extra bits needed for Function Apps.

    Duplicated Logs / Log Filtering

    As mentioned above, if you follow the guidance here - https://learn.microsoft.com/en-us/azure/azure-functions/opentelemetry-howto?tabs=otlp-export&pivots=programming-language-csharp - you are instructed to add UseFunctionsWorkerDefaults(), which under the hood has the following really important line -

                builder.Services
                    // Tells the host to no longer emit telemetry on behalf of the worker.
                    .Configure<WorkerOptions>(workerOptions => workerOptions.Capabilities["WorkerOpenTelemetryEnabled"] = bool.TrueString);
    

    Without this (and potentially the other bits in UseFunctionsWorkerDefaults(), which have interesting features in FunctionsResourceDetector) , the Aspire template with a new Function App with "enlist in Aspire orchestration" ticked simply isn't correct and things are missing, leading to the duplication and inability to filter.

    I think we can add our own workarounds for this part of the problem based on the above, but it's not a good experience out of the box at the moment.

    Service Bus Trigger Trace Noise

    Unfortunately, I haven't been able to resolve this one. The traces look to be coming from the functions host, so I don't have a way to filter them out with a sampler in the worker code. The aspire function hosting package switches the host's telemetryMode to OpenTelemetry, which is probably a good move. But then you just get thousands of traces building up, similar to the issue logged previously about blobs and storage. Is there a way of controlling this via environment variables or host.json?

    It's an annoyance locally, but I'm more concerned about when we deploy to azure. That's a lot of unnecessary telemetry.

    Rohit Ranjan (@RohitRanjanMS) any advice would be gratefully received

  8. captainsafia commented on Aug 11, 2025

    @captainsafia
    Contributor

    Rohit Ranjan (@RohitRanjanMS) I think you came to the same conclusions as Andrew Smith (@DGAISmith) above based on our other thread. Did you have any thoughts on what the ideal fix here would be?

  9. earloc commented on Aug 12, 2025

    @earloc

    This is affecting us heavily as well, which makes it very hard to even grasp, if our logs are actually helping when identifying runtime issues. The sheer amount of traces quickly hits the ceiling of maximum number of entries aspire-dashboard keeps in-memory.

    Is there any workaround known so far, which let's us at least filter the noise based on some log-level, for now?

  10. RohitRanjanMS commented on Aug 12, 2025

    @RohitRanjanMS

    Yes, I understand the pain. I am going to suppress the noise. Working on a PR for this.

  11. RohitRanjanMS commented on Sep 8, 2025

    @RohitRanjanMS

    This is fixed, will be available in the next host release (1043) - Azure/azure-functions-host#11260

  12. earloc commented on Sep 8, 2025

    @earloc

    Great, really looking forward to this!

    So we would need to update our local azure-functions-core-tools for this to take effect?

  13. RohitRanjanMS commented on Sep 8, 2025

    @RohitRanjanMS

    yes, it will take few weeks before we have a new core tools release.

  14. DGAISmith commented on Sep 8, 2025

    @DGAISmith
    Author

    Wonderful, I'll keep an eye out for the new tools release. This will help a lot, many thanks.

  15. biltongza commented on Oct 22, 2025

    @biltongza

    It looks like this is released, given that https://github.com/Azure/azure-functions-host/releases/tag/v4.1043.200 is out and my functions runtime matches that version number.

    Is there anything outstanding for this?

  16. DGAISmith commented on Oct 23, 2025

    @DGAISmith
    Author

    It looks like this is released, given that https://github.com/Azure/azure-functions-host/releases/tag/v4.1043.200 is out and my functions runtime matches that version number.

    Is there anything outstanding for this?

    I'd need to check more thoroughly, but I'd need the 4.1043 to appear via the function-core-tools and in visual studio before this one goes away entirely for my team. Otherwise we still have the noise locally, even if it's been resolved when apps are deployed to azure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-integrationsazure-functions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions