This Worker extension provides the ability to modify and/or skip RequestTelemetry
events generated in the Azure Functions host.
-
Add the Worker.Extensions.HttpTelemetryProcessor NuGet package to your Isolated Azure Functions project.
-
Apply the
HttpTelemetryProcessor
attribute to your HTTP trigger function parameters. Configure the following properties:DiscardSuccessfulRequestTelemetry
: When set totrue
,RequestTelemetry
events generated by the functions host will be discarded if the trigger response code is< 400
.FailureStatusCodeIsRequestFailure
: When set totrue
, theSuccess
property ofRequestTelemetry
will be set tofalse
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 ...
}
-
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 theHTTP 2xx
chart in the functions overview, will not display data for successful events. Similarly, theMonitor
tab will show inaccurateSuccess Count
, and no items will be listed in theInvocation Traces
table. This is not an exhaustive list of the potential impacts. -
Aggregate telemetry, such as
Total Execution Count
andSuccessful Execution Count
, is not affected. These metrics use aggregated event data created before theHttpTelemetryProcessor
discards individual request telemetry.
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.