0

Application Insights allows to capture telemetry data for Page views, Requests, Exceptions and couple of other kinds. If I want to capture data for only exceptions, can I setup up my telemetry configuration to support this?. I am on an Asp.Net core web app deployed on Azure.

Nitin Rastogi
  • 1,446
  • 16
  • 30

2 Answers2

1

I was able to implement the facility by writing a custom telemetry processor as documented here.

Nitin Rastogi
  • 1,446
  • 16
  • 30
0

This is exactly what I'm doing here in my apps.

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
}
Jone Polvora
  • 2,184
  • 1
  • 22
  • 33