我正在使用 Node ( https://www.npmjs.com/package/applicationinsights ) 的 Azure App Insight 模块,该模块可以选择通过 appInsights.defaultClient.config.samplingPercentage 设置示例。
通过这种方式,所有类型的日志都将被采样(跟踪、请求、异常等)。有没有办法对除异常之外的所有内容进行采样(我想将 100% 的异常发布到应用洞察)。
谢谢
最佳答案
编辑:需要进行一些更改才能使代码正常工作
您可以尝试使用 Telemetry Processors in node.js .
示例代码:
function samplingControl ( envelope, context ) {
if (envelope.data.baseType === "ExceptionData") {
//all exception data will be sent
envelope.sampleRate = 100;
}
else
{
envelope.sampleRate = 33;
}
return true;
}
appInsights.defaultClient.addTelemetryProcessor(samplingControl);
关于node.js - Node js 应用程序洞察采样,对除错误/异常之外的所有内容进行采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61094336/