I'm struggling to disable dependency tracking in a project that uses Azure Functions (v4) using .NET 9 as an Isolated Process. I want to do this as these entries are clogging up our log files with information we don't use, which is ultimately costing us money.
Our host.json files looks as follows:
{
"version": "2.0",
// By default these new logging filters are filtered out by the function logs. You need to modify the host.json file
// to opt-in for additional filters and categories.
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
},
"enableDependencyTracking": false
},
"logLevel": {
"Witness.Io": "Information"
}
},
"extensions": {
"queues": {
"maxPollingInterval": "00:00:10.000",
"batchSize": 1 // The number of queue messages that the Functions runtime retrieves simultaneously and processes in parallel.
}
},
// Set functionTimeout to 10 minutes
"functionTimeout": "00:10:00"
}
This didn't resolve the issue so I tried writing a telemetry processor based on a blog post I found here - https://github.com/RohitRanjanMS/ApplicationInsightsDemo/blob/main/Isolated/IsolatedApplicationInsightsDemo/CustomTelemetryProcessor.cs.
The Main method of our Program.cs looks like this:
public static void Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWebApplication(config =>
{
config.UseNewtonsoftJson();
})
.ConfigureServices(services =>
{
// Disable dependency tracking - based on approach detailed here - https://github.com/RohitRanjanMS/ApplicationInsightsDemo/blob/main/Isolated/IsolatedApplicationInsightsDemo/CustomTelemetryProcessor.cs.
services.AddApplicationInsightsTelemetryProcessor<DependencyTrackingProcessor>();
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
var keyVaultService = new KeyVaultService(new Uri(Environment.GetEnvironmentVariable("KEY_VAULT_URI") ?? throw new InvalidOperationException($"Missing environment variable: '{"KEY_VAULT_URI"}'.")));
services.AddKeyVaultService(keyVaultService);
services.AddTransient<IFunctionEnvironment, FunctionEnvironment>();
services.AddTransient<IAuditEntityRepository, AuditEntityRepository>();
services.AddConfigRepository<IUserConfigurationEntityRepository, UserConfigurationEntityRepository>();
services.AddTransient<IAutoDeleteExperimentMessageRepository, AutoDeleteExperimentMessageRepository>();
services.AddTransient<IExperimentEntityRepository, ExperimentEntityRepository>();
services.AddTransient<IExperimentBlobRepository, ExperimentBlobRepository>();
services.AddTransient<IExperimentMessageQueueRepository, ExperimentMessageQueueRepository>();
services.AddTransient<IExperimentCompletedQueueRepository, ExperimentCompletedQueueRepository>();
services.AddTransient<IScenarioEntityRepository, ScenarioEntityRepository>();
services.AddTransient<IScenarioCompletedQueueRepository, ScenarioCompletedQueueRepository>();
services.AddTransient<IReplicationEntityRepository, ReplicationEntityRepository>();
services.AddTransient<IReplicationServicesScalingQueueRepository, ReplicationServicesScalingQueueRepository>();
services.AddTransient<IReplicationQueueRepository, ReplicationQueueRepository>();
services.AddTransient<IReplicationCompletedQueueRepository, ReplicationCompletedQueueRepository>();
services.AddTransient<IShutdownServicesMessageQueueRepository, ShutdownServicesMessageQueueRepository>();
services.AddTransient<IRunningCoresInfoEntityRepository, RunningCoresInfoEntityRepository>();
services.AddTransient<ILicenseCostUsage, LicenseCostUsage>();
services.AddTransient<ILicenseCostUsageEntityRepository, LicenseCostUsageEntityRepository>();
services.AddTransient<Experiment>();
services.AddTransient<Scenario>();
services.AddTransient<Replication>();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
LogConfiguration(keyVaultService);
})
.ConfigureLogging(logging =>
{
// Allow all Information-level App Insights logs through (this defaults to Warning).
RemoveApplicationInsightsFilter(logging.Services);
})
.Build();
host.Run();
}
The processor looks as follows:
/// <summary>
/// Dependency tracking processor.
/// </summary>
/// <remarks>This is used to filter out the dependency tracking logs that we don't want.</remarks>
public class DependencyTrackingProcessor : ITelemetryProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="DependencyTrackingProcessor"/> class. Link processors to each other in the chain.
/// </summary>
/// <param name="nextProcessor">The next telemetry processor.</param>
public DependencyTrackingProcessor(ITelemetryProcessor nextProcessor)
{
NextProcessor = nextProcessor;
}
private ITelemetryProcessor NextProcessor { get; }
/// <inheritdoc/>
public void Process(ITelemetry item)
{
if (item is DependencyTelemetry)
{
// Do not send telemetry for dependency tracking.
return;
}
// Call the next processor in the chain.
NextProcessor.Process(item);
}
}
None of this seems to have any impact. Is anyone able to tell me what I'm doing wrong?
Thanks
Kevin


{ "version": "2.0", "logging": { "applicationInsights": { "enableDependencyTracking": false, "samplingSettings": { "isEnabled": true } } } }