我们可以确定哪个依赖项与应用程序 Insights 中的代码中的哪个请求遥测相关联吗
Can we determine which dependency is associated with which request telemetry in the code in appication Insights
我需要抑制为运行状况检查 api 请求生成的所有自动生成的依赖项遥测数据。有没有办法在代码中识别从哪个请求遥测生成哪个依赖遥测,然后在遥测处理器中删除它们
如果你知道the health check api request
的操作名称,那是有可能的。关于如何获取api请求的操作名称,可以在Telemetry processor
class.
中设置检查点
例如操作名称是“Get api/check”,那么你可以在你自定义的Telemetry processor中编写如下代码class:
//your other code
public void Process(ITelemetry item)
{
if (!ProcessItem(item)) { return; }
this.Next.Process(item);
}
private bool ProcessItem(ITelemetry item)
{
if (item is DependencyTelemetry dependencyTelemetry)
{
var op_name = dependencyTelemetry.Context.Operation.Name;
if (op_name == "Get api/check")//please remember replace it to the real operation name.
{
return false;
}
}
return true;
}
我需要抑制为运行状况检查 api 请求生成的所有自动生成的依赖项遥测数据。有没有办法在代码中识别从哪个请求遥测生成哪个依赖遥测,然后在遥测处理器中删除它们
如果你知道the health check api request
的操作名称,那是有可能的。关于如何获取api请求的操作名称,可以在Telemetry processor
class.
例如操作名称是“Get api/check”,那么你可以在你自定义的Telemetry processor中编写如下代码class:
//your other code
public void Process(ITelemetry item)
{
if (!ProcessItem(item)) { return; }
this.Next.Process(item);
}
private bool ProcessItem(ITelemetry item)
{
if (item is DependencyTelemetry dependencyTelemetry)
{
var op_name = dependencyTelemetry.Context.Operation.Name;
if (op_name == "Get api/check")//please remember replace it to the real operation name.
{
return false;
}
}
return true;
}