.Net Application Insights - 处理器内的遥测客户端?

问题描述 投票:0回答:1

我有一个遥测处理器,可以根据请求和依赖项捕获一些指标。我需要这个处理器有一个

TelemetryClient
的实例,以便它可以记录指标聚合。

但是当我尝试

services.AddSingleton<Microsoft.ApplicationInsights.AspNetCore.ITelemetryProcessorFactory>(builder =>
{
     var svc = builder.GetRequiredService<TelemetryClient>(); //loop here!
     return new MyCustomProcessor(svc);
});

我陷入了无限循环! (不是

StackOverflowException

谁能指出我做错了什么?

c# asp.net .net azure-application-insights
1个回答
0
投票

您可能需要像这样添加遥测处理器:

services.AddApplicationInsightsTelemetryProcessor<MyCustomProcessor>();
© www.soinside.com 2019 - 2024. All rights reserved.