Custom HTTP Request Telemetry Processing for Isolated Azure Functions

This Worker extension provides the ability to modify and/or skip RequestTelemetry events generated in the Azure Functions host.

Usage

  1. Add the Worker.Extensions.HttpTelemetryProcessor NuGet package to your Isolated Azure Functions project.

  2. Apply the HttpTelemetryProcessor attribute to your HTTP trigger function parameters. Configure the following properties:

    • DiscardSuccessfulRequestTelemetry: When set to true, RequestTelemetry events generated by the functions host will be discarded if the trigger response code is < 400.
    • FailureStatusCodeIsRequestFailure: When set to true, the Success property of RequestTelemetry will be set to false if the trigger response code is >= 400.

Example:

[Function("Ping")]
public HttpResponseData Ping([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "ping")] HttpRequestData req, 
[HttpTelemetryProcessor( DiscardSuccessfulRequestTelemetry = true, FailureStatusCodeIsRequestFailure = true)] object ignore)
{
    // ... your code ...
}

Notes

  • When DiscardSuccessfulRequestTelemetry is enabled, specific metrics in your Azure Function will be affected. For example, stats and charts reliant on individual request telemetry, such as the HTTP 2xx chart in the functions overview, will not display data for successful events. Similarly, the Monitor tab will show inaccurate Success Count, and no items will be listed in the Invocation Traces table. This is not an exhaustive list of the potential impacts.

  • Aggregate telemetry, such as Total Execution Count and Successful Execution Count, is not affected. These metrics use aggregated event data created before the HttpTelemetryProcessor discards individual request telemetry.

How Does It Work?

The WebJobs extension WebJobs.Extensions.HttpTelemetry (available on NuGet) will be loaded by the functions host. The functions.metadata file is parsed during the startup to determine the configuration of each HttpTelemetryProcessor attribute on your HTTP triggers. The existing TelemetryConfiguration registered by the function host is then overridden with a new configuration that includes our custom HttpTelemetryProcessor. This processor is responsible for modifying or discarding RequestTelemetry events based on your configurations.