node js应用程序见解采样,对除错误/异常之外的所有采样

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

我正在为节点(https://www.npmjs.com/package/applicationinsights)使用Azure应用洞察模块,该模块具有通过appInsights.defaultClient.config.samplingPercentage设置样本的选项。

这样,所有类型的日志都将被采样(跟踪,请求,异常等)。除异常外,是否有其他方法可以采样(我想将100%异常发布给应用程序洞察)。

谢谢

node.js azure-application-insights
1个回答
1
投票

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);
© www.soinside.com 2019 - 2024. All rights reserved.