I have a Kubernetes app that is constantly logging ServiceBusReceiver.Receive Dependency calls. It is creating 2000 logs per hour, per instance. In the TelemtryClient there are only custom methods for TrackEvent and TrackException so these look like they are coming from somewhere else and I haven't been able to trace it to disable or find out why its logging so much. The TrackDependency method is part of the built in Microsoft.ApplicationInsights.TelemetryClient package. I have changed versions of packages to match another messaging app I have with no luck, and also updated packages to latest versions also with no luck. There isn't much other info in the logs to trace it.
SERVICEBUS ServiceBusReceiver.Receive
Type: servicebus
Call status: true
Duration: 1.0 mins
Name: ServiceBusReceiver.Receive
Telemetry type: dependency
Application version: 4.19.0.0
SDK version dotnetc:2.21.0-429
Sample rate: 1
Performance: 1min-2min
Base name: ServiceBusReceiver.Receive
Other info about packages and versions installed:
Sdk="Microsoft.NET.Sdk"
net6.0
AzureFunctionsVersion v4
"AutoMapper.Extensions.Microsoft.DependencyInjection" Version="4.0.1"
"Azure.Messaging.ServiceBus" Version="7.10.0"
"Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.4.0"
"Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33"
"Microsoft.NET.Sdk.Functions" Version="4.0.1"
"Microsoft.Azure.Functions.Extensions" Version="1.1.0"
"Microsoft.Extensions.Azure" Version="1.2.0"
"Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="5.1.0"
"Microsoft.Extensions.Caching.Memory" Version="6.0.1"
"Polly" Version="7.1.0"
"Scrutor" Version="4.1.0"
For that, you can write a TelemetryProcessor:
Telemetry processors allow you to completely replace or discard a telemetry item.
It could look like this:
public class ServiceBusTelemetryReducer : ITelemetryProcessor
{
private readonly ITelemetryProcessor _next;
public ServiceBusTelemetryReducer(ITelemetryProcessor next)
{
_next = next;
}
public void Process(ITelemetry item)
{
var isServiceBusReceiveTelemetry = item is DependencyTelemetry telemetry
&& telemetry.Type == "Azure Service Bus"
&& telemetry.Name == "ServiceBusReceiver.Receive";
// Only process telemetry that is relevant
if (!isServiceBusReceiveTelemetry)
_next.Process(item);
}
}
Do not forget to register the processor:
services.AddApplicationInsightsTelemetryProcessor<ServiceBusTelemetryReducer>();