我正在为节点(https://www.npmjs.com/package/applicationinsights)使用Azure应用洞察模块,该模块具有通过appInsights.defaultClient.config.samplingPercentage设置样本的选项。
这样,所有类型的日志都将被采样(跟踪,请求,异常等)。除异常外,是否有其他方法可以采样(我想将100%异常发布给应用程序洞察)。
谢谢
EDIT:为了使代码正常工作,需要进行一些更改
您可以用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);