我有一个遥测处理器,可以根据请求和依赖项捕获一些指标。我需要这个处理器有一个
TelemetryClient
的实例,以便它可以记录指标聚合。
但是当我尝试
services.AddSingleton<Microsoft.ApplicationInsights.AspNetCore.ITelemetryProcessorFactory>(builder =>
{
var svc = builder.GetRequiredService<TelemetryClient>(); //loop here!
return new MyCustomProcessor(svc);
});
我陷入了无限循环! (不是
StackOverflowException
)
谁能指出我做错了什么?
您可能需要像这样添加遥测处理器:
services.AddApplicationInsightsTelemetryProcessor<MyCustomProcessor>();