我有一个带有几个控制器的Spring Boot应用程序,我想要跟踪它们的依赖关系(包括出站Http请求)。这一切都像预期的那样工作。但是,我有一个用于运行状况检查的控制器(返回204),但我不希望使用遥测。所有其他响应都提到了自定义代码组件,但根据the documentation的说法,这应该可以在AI-Agent.xml配置中完成。
<BuiltInProcessors>
<Processor type="RequestTelemetryFilter">
<Add name="NotNeededResponseCodes" value="204" />
</Processor>
</BuiltInProcessors>我注意到类路径上有两个核心实例(一个来自ai- RequestTelemtryFilter,另一个来自ai-web,在我调试时这两个实例都没有命中)。
发布于 2019-03-14 22:12:23
配置代理(通过AI-Agent.xml)与配置自定义遥测(通过Applicationinsights.xml)不同。Spring boot +该代理需要使用自定义遥测处理器,并通过@Bean引入您的配置。AI-Agent中不需要额外的XML。
public class HealthCheckTelemetryFilter implements TelemetryProcessor
{
public HealthCheckTelemetryFilter()
{
// TODO Auto-generated constructor stub
}
@Override
public boolean process(Telemetry telemetry)
{
RequestTelemetry reqTel = (RequestTelemetry) telemetry;
if(reqTel.getResponseCode().equals(HttpStatus.NO_CONTENT.toString()))
return false;
else
return true;
}
}注意:不要忘记适当的类型检查
https://stackoverflow.com/questions/55151758
复制相似问题