我们将 Azure Application Insights 用于网站(Azure 应用服务),并且 SQL 依赖项日志正在填满日志。
我们已在 ApplicationInsights.config 中注释了以下行
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>
我们可以在哪里禁用这些?
最佳答案
我在 SO 中发现了类似的问题,涉及禁用 SQL 依赖项遥测(Application Insights),其中 James Davis 提供了解决方案](App Insights: Disable SQL Dependency telemetry)“https://stackoverflow.com/q/38320886/16630138) ") 这可能有助于满足您的要求
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.DataContracts;
public class SuccessfulDependencyFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
// next will point to the next TelemetryProcessor in the chain.
public SuccessfulDependencyFilter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
// To filter out an item, return without calling the next processor.
if (!OKtoSend(item)) { return; }
this.Next.Process(item);
}
// Example: replace with your own criteria.
private bool OKtoSend (ITelemetry item)
{
var dependency = item as DependencyTelemetry;
if (dependency == null) return true;
return dependency.Success != true;
}
}
引用link
关于azure - 应用程序洞察 : How to disable SQL Dependency telemetry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74602263/