Go beyond static code analysis: Understand how your data flows through a process from start to finish
Tags: java, webdev, tutorial, career
Published: 2023-05-12 19:02:33

A tutorial for process recording for Java with AppMap.

Once you’ve recorded a process, AppMap allows you to get a bird's eye view of everything going on in a process from start to finish by drilling down into the individual functions and classes. This allows you to understand how data flows through the whole process.

This article teaches how to set up process recording in Java with AppMap. We will use IntelliJ IDEA and a pet clinic application as the example repo. 

**First, let’s configure.** 

To do this, we're going to take a look at run configurations. Run configurations are a convenient way to run your application using different environments with different environment variables. In addition, run configurations allow you to set up multiple scenarios or situations your app could run in. 

1. Edit your run configuration by adding a specific variable to the virtual machine environment.
2. To do that, click on the drop-down in the upper right corner of your editor and select edit configurations.
    ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3510g0mzl5e4h5j639zj.png)

3. From here, you should see a field labeled “VM options” under the "build and run" section. The field may be hidden by default, so if you don't see it, select modify options, then under Java, select add "VM options."

    ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xetcjkmqs9a6lrobx3q.png)

4. A new field should appear labeled "VM Options," inside of which we are going to place this option:  `-Dappmap.recording.auto=true`
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oelq9l2qymexgxka3hz1.png)


**Next, let’s start a recording.**

1. Select the run configuration you created, and click the "Start with AppMap” button.
2. Once the application is running, AppMap will record the process.

It is not readily apparent, but there is a process recording running. You can verify that by looking at the bottom left-hand corner next to the AppMap logo. You should see a green dot indicating that a recording is active.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rs6jjggxol0kk188xb2u.png)


**Finally, interact with your application**

1. Visit the application running in your browser and use it as you normally would.
2. Once you have interacted with your application, press the "Stop" button to end the process.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7vn2w2ch3ex0tmr6p31.png)

The AppMap recording will stop as well. Soon you will see a new recording designated by a number in your list of AppMaps, it will be named by the date.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkxmtoatbe21ox7xtuxl.png)


**How to use your maps**

View your maps, and use them to [navigate to code](https://appmap.io/blog/2023/05/05/how-to-navigate-a-new-codespace-with-appmap/) and make changes. You may find behavioral and performance issues by opening the runtime analysis option. [Use sequence diagrams](https://appmap.io/blog/2023/05/05/automatically-generate-interactive-sequence-diagrams-of-your-java-codes-runtime-behavior/), or [generate OpenAPI documentation](https://appmap.io/blog/2022/12/14/automatically-generating-openapi-docs-for-mastodon-copy/) based on this new flow.

Process recording can be done with Python, Javascript, and Ruby as well. Find AppMap in the [VS Code marketplace](https://marketplace.visualstudio.com/items?itemName=appland.appmap) as well as JetBrains.