node.js - Node js 应用程序洞察采样,对除错误/异常之外的所有内容进行采样

标签 node.js azure azure-application-insights

我正在使用 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/

相关文章:

node.js - 将 S3 对象的内容流式传输到哈希算法 node.js

powershell - 在 VSTS 版本定义中的 Azure CLI 中使用服务主体

asp.net-mvc - Azure 云服务的保留 IP 地址不起作用

azure - 应用程序洞察 : Analytics - how to extract string at specific position

azure - Application Insights 采样会采样掉异常吗?

javascript - 在可读事件监听器回调中读取时,Node 的 process.stdin 可读流记录 Null

node.js - nodejs/express : does calling next() automatically return the function it is called from?

node.js - 如何在此 Kubernetes 示例中选择主 Redis pod?

azure - 如何查找访问使用 Azure 应用服务部署的 Web 应用程序的用户的 IP 地址?

Azure KQL - 在时间表之上创建总平均线