【发布时间】:2017-10-05 17:59:25
【问题描述】:
Application Insights 允许捕获遥测数据 页面浏览量、请求、异常和其他几种。如果我只想为异常捕获数据,我可以设置我的遥测配置来支持这个吗?我正在使用 Azure 上部署的 Asp.Net 核心 Web 应用程序。
【问题讨论】:
标签: azure azure-application-insights telemetry
Application Insights 允许捕获遥测数据 页面浏览量、请求、异常和其他几种。如果我只想为异常捕获数据,我可以设置我的遥测配置来支持这个吗?我正在使用 Azure 上部署的 Asp.Net 核心 Web 应用程序。
【问题讨论】:
标签: azure azure-application-insights telemetry
我能够通过编写自定义遥测处理器来实现该设施,如文档 here 所述。
【讨论】:
这正是我在我的应用程序中所做的。
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
}
【讨论】: