Azure/azure-functions-dotnet-worker

Unable to disable Request Telemetry (App Insights) for ServiceBusTrigger .NET 8 C# Isolated Azure Function

rbychiang opened this issue · 0 comments

I'm encountering an issue with filtering out successful request telemetry in a ServiceBusTrigger .NET 8 isolated function. Despite trying various solutions, I've been unable to achieve the desired outcome. Below, I've outlined the solutions attempted:

  • Used Telemetry Processor to filter out successful requests (DID NOT WORK) Note: Probably this is expected due to this issue #2024
// the telemetry processor
internal sealed class SuccessfulRequestTelemetryFilter(ITelemetryProcessor next) : ITelemetryProcessor
{
    private readonly ITelemetryProcessor _next = next;

    public void Process(ITelemetry item)
    {
        if (!IsOkToSend(item)) return;

        _next.Process(item);
    }

    private static bool IsOkToSend(ITelemetry item)
    {
        RequestTelemetry? request = item as RequestTelemetry;
        if (request == null) return true;

        return request.Success != true;
    }
}

// register
services.AddApplicationInsightsTelemetryProcessor<SuccessfulRequestTelemetryFilter>();
  • So I attempted to disable all requests from the host to see if that did anything. Updated host.json's log level default to NONE (DID NOT WORK)
{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    },
    "loglevel": {
      "default": "None"
    }
  }
}
  • Maybe if I update the Host.Results directly? Assuming the Error level should avoid successful requests. Updated host.json's log level Host.Results to ERROR (DID NOT WORK)
{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    },
    "loglevel": {
      "default": "Warning",
      "Host.Results": "Error"
    }
  }
}
  • Updated log level to None to ApplicationInsightsLoggerProvider. (DID NOT WORK)
.ConfigureLogging(logging =>
     {
         logging.AddFilter<ApplicationInsightsLoggerProvider>(null, LogLevel.None);
    })

At this juncture, I'm seeking guidance from the community. Should I continue exploring alternative solutions, or is this likely indicative of a bug within the ServiceBusTrigger .NET 8 isolated function implementation?

Your insights and experiences would be greatly appreciated in resolving this issue.