ola
ola

Reputation: 139

Are exceptions counted for JVM lifetime in Java Flight Recorder?

I have run a Java Flight Recorder recording for 2 minutes on a JBoss EAP 6.1 app server under load. I enabled exception counting (Java Application => Java Exception => Enabled=true) and I'm surprised by the number of reported exceptions.

When I look in the Events => Histogram view with event type "Java Application/ Java Exception" and Group by "Event Thread", 10 threads have over 2000 exceptions each. 3 of them have over 3000 exceptions.

This is the total number of reported creations of Throwable or Error:

Stack Trace                          Sample Count
java.lang.Throwable.<init>()              128 059
java.lang.Throwable.<init>(String)        116 107
java.lang.Throwable.<init>(Throwable)      39 207
java.lang.Error.<init>()                        7
java.lang.Throwable.<init>(String, Throwable)   2

So I'm wondering if all these exceptions occurred during the 2 minute period I recorded or are they counted since the start of the JVM?

Upvotes: 0

Views: 972

Answers (2)

Kire Haglin
Kire Haglin

Reputation: 7069

"Sample Count" column in the Histogram tab aggregates the number of events with respect to a field value, in your case I believe the top frame of the stack trace. So the number 128 059 means there were that many events emitted with a top frame of "java.lang.Throwable.<init>()" during your recording.

This may not be the information you are looking for.

I recommend using the recording template to enable Exceptions / Errors, and looking at the Exceptions tab, instead of editing settings for individual events and using the Histogram tab.

Upvotes: 1

Klara
Klara

Reputation: 3005

TL;DR: Java Exception events only count what happens during the recording. The Exception Statistics event count exceptions during the JVM lifetime (or some other 'JVM global' time).

There are two different data points, the Java Exception and Java Error events, and the Statistics/Throwables event. If you only look at Java Exception/Error, the events you have in the recording are those that occcured during that time. The Statistics/Throwables event is taken with regular intervals, and might be from the start of the JVM, or possibly from the start of the JFR engine, or from the start of the first JFR recording occuring in the running JVM. It's mostly interesting to compare this values relative to each other. This event is displayed in the top of the Code/Exceptions tab, in the two text fields.

Also note that the Exception/Error events occur in the constructor, not when it's actually thrown

If your program creates a lot of Java Error events, there is some trouble with double bookkeeping of these, so the numbers might be incorrect (this is something we have compensated for in the next JMC version, but not in JMC 5.5) Other Throwable subclasses will show up as Exception events.

Upvotes: 0

Related Questions