Part I Why Use the API?

Use the Flight Recorder API for more comprehensive application monitoring; you can analyze in greater detail events generated by applications, the JVM, and the operating system. In addition, you can create your own events, record your own data, and view and parse the recordings.

For example, you might create events and recordings for the following scenarios:

  • To identify slow HTTP GET requests: A client application sends a request to a web server and it takes a long time for the request to be processed. To troubleshoot this problem, you can create an event that triggers if the request takes more than five seconds to process. You can also correlate these requests with JVM events, such as garbage collection or thread contention, which might impact web server performance.

  • To track slow-running SQL queries: Some SQL queries take a long time to execute in a database server. To identify the problem, you can create an event to log all the SQL queries, and then analyze the recordings to track the slowest-running queries.

Flight Recorder API or Java Logging API?

The Java Logging API (see the package java.util.logging) captures information such as security failures, configuration errors, performance bottlenecks, and bugs in the application or platform. However, compared with the Java Logging API, the Flight Recorder API provides you with more information in the recording it generates (and in the events it records), more information regarding the context in which an event occurs, and more control over the timing of events.