【问题标题】:Application Insights selective telemetry data captureApplication Insights 选择性遥测数据捕获
【发布时间】:2017-10-05 17:59:25
【问题描述】:

Application Insights 允许捕获遥测数据 页面浏览量、请求、异常和其他几种。如果我只想为异常捕获数据,我可以设置我的遥测配置来支持这个吗?我正在使用 Azure 上部署的 Asp.Net 核心 Web 应用程序。

【问题讨论】:

    标签: azure azure-application-insights telemetry


    【解决方案1】:

    我能够通过编写自定义遥测处理器来实现该设施,如文档 here 所述。

    【讨论】:

      【解决方案2】:

      这正是我在我的应用程序中所做的。

      const filterTelemetry = (envelope) => {
        if (envelope.data.baseType === 'ExceptionData') {
          envelope.sampleRate = 100
          return true
        }
      
        if (envelope.data.baseType === 'RequestData') {
          if (envelope.data.baseData.responseCode >= 400) {
            envelope.sampleRate = 100
            return true
          }
        }
      
        if (envelope.data.baseType === 'RemoteDependencyData') {
          if (envelope.data.baseData.resultCode >= 400) {
            envelope.sampleRate = 100
            return true
          }
        }
      
        if (envelope.data.baseType === 'MetricData') {
          envelope.sampleRate = Number(process.env.APPINSIGHTS_SAMPLING) || 100
          return true
        }
      
        return false
      }
      

      【讨论】:

        猜你喜欢
        • 2021-01-14
        • 1970-01-01
        • 1970-01-01
        • 2020-02-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-12
        相关资源
        最近更新 更多