我有一个 Kubernetes 应用程序,它不断记录 ServiceBusReceiver.Receive 依赖项调用。每个实例每小时创建 2000 个日志。 在 TelemtryClient 中,只有 TrackEvent 和 TrackException 的自定义方法,因此这些看起来像是来自其他地方,我无法跟踪它以禁用或找出为什么它的日志记录如此之多。 TrackDependency 方法是内置 Microsoft.ApplicationInsights.TelemetryClient 包的一部分。我已经更改了软件包的版本以匹配我没有运气的另一个消息应用程序,并且也将软件包更新到最新版本也没有运气。日志中没有太多其他信息可以追踪它。
SERVICEBUS ServiceBusReceiver.Receive
- 依赖属性
类型:服务总线
通话状态:true
时长:1.0 分钟
名称:ServiceBusReceiver.Receive
遥测类型:依赖
应用版本:4.19.0.0
SDK版本dotnetc:2.21.0-429
采样率:1
性能:1min-2min
基本名称:ServiceBusReceiver.Receive
有关已安装的软件包和版本的其他信息:
Sdk="Microsoft.NET.Sdk"
net6.0
AzureFunctions版本 v4
“AutoMapper.Extensions.Microsoft.DependencyInjection”版本=“4.0.1”
“Azure.Messaging.ServiceBus”版本=“7.10.0”
“Microsoft.Azure.WebJobs.Extensions.ServiceBus”版本=“5.4.0”
“Microsoft.Azure.WebJobs.Logging.ApplicationInsights”版本=“3.0.33”
“Microsoft.NET.Sdk.Functions”版本=“4.0.1”
“Microsoft.Azure.Functions.Extensions”版本=“1.1.0”
“Microsoft.Extensions.Azure”版本=“1.2.0”
“Microsoft.Extensions.Configuration.AzureAppConfiguration”版本=“5.1.0”
“Microsoft.Extensions.Caching.Memory”版本=“6.0.1”
“波莉”版本=“7.1.0”
“Scrutor”版本=“4.1.0”
最佳答案
为此,您可以编写 TelemetryProcessor :
Telemetry processors allow you to completely replace or discard a telemetry item.
它可能看起来像这样:
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);
}
}
不要忘记注册处理器:
services.AddApplicationInsightsTelemetryProcessor<ServiceBusTelemetryReducer>();
关于azure - 如何停止将过多的 ServiceBusReceiver.Receive 依赖项日志记录到 App Insights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76172584/