Not all errors/exceptions are reported by the Java APM agent

Hi @bbking,

First, we need to distinguish two things:

  • HTTP 5xx status code for HTTP responses that indicate a server error
  • Exceptions that may be thrown by application code and are reported as Errors in Kibana

Those two things are captured separately, thus having one of them does not imply the other, which means you can have 5xx + Error, 5xx without Error, Error without 5xx or even multiple Errors reported for a single transaction.

Agent instruments methods by wrapping their body, and captures exceptions in a similar way as the following pseudo-code:

Original method before instrumentation:

void methodToInstrument() {
  // method body, may throw any Exception
}

Instrumented method

void methodToInstrument() {
  try {
    // method body, may throw any Exception
  } catch (Exception thrown){
    // report exception as an Error
   throw thrown; // rethrow the original exception to preserve original behavior
  }
}

Thus, that means that:

  • exceptions that are thrown and caught within method body (or below) aren't reported as errors
  • exceptions that are thrown in the calling code that calls methodToInstrument() are not captured as errors (for example within internal application server request processing that calls the instrumented method).
  • exceptions that are thrown and not caught within method body are reported as errors, aka "the ones that escape the method body"

In your case, you need to identify what transactions are triggering 5xx responses without having errors:

  • is there any stack trace visible in tomcat log for those ?
  • is there any servlet filter that wraps execution in a try/catch block, which is common for logging ?