In this video
Dive into the Code objects view, a high level view of code functions, HTTP requests, and SQL queries across the entire set of your AppMaps and learn how to locate and navigate to an AppMap from code reference pins on your code functions.
Rails Sample Application
Welcome to AppMap, In this tutorial we will be diving into advanced navigation of AppMaps - the Code Objects view. We’ll answer the question, “What if I have a lot of AppMaps and I don’t know where exactly to look?”
In this view, we collect all the different code functions and HTTP server requests and SQL queries all into one list. Every request, query, and function call that occurs anywhere in the whole set of AppMaps will be in this list.
There are three sections to the Code Objects view. The first section is the Code view, this will show packages, classes, and functions, it will show the framework code as well as my code, essentially everything present within your Appmaps. We can click on a function to navigate directly to the code. In this example, I’ll navigate to my Application controllers, and view the Microposts controller. This will take me directly to the code for this function. This is a great way to see more comprehensively what you have across your code base.
In the HTTP Service request list, you can see basically a mini spec file showing you what routes are available across all of your AppMaps.
If this route only exists in a single AppMap, you’ll be taken directly to the AppMap for this request, but if the route exists in multiple AppMaps you’ll get a VScode picker to choose which one to open.
Here is this route, and here it is shown in a trace view, and you’ll see the status code for that is 302 which is a redirect.
The final section of Code Objects is a list of all the SQL queries across your AppMaps. Just like before, if you click into it and it is unique across your AppMap set then you’ll be sent directly to the AppMap or the quick picker will prompt you to open one.
The code view is a handy way to navigate your code base, similar to the file view you’d get in VS Code except this code view will only show the code that participated in your test case recordings or remote recordings.
But it’s more common to simply be navigating within the code itself. So what if you want to get to AppMaps from within the code?
What we do is drop an AppMap pin on every function that has been recorded within an AppMap. We can navigate thru some of the different controllers.
The pins give you quick access to the AppMap. Some of these route functions are mapped and some are not. In addition to giving you an easy way to open up this particular function within an AppMap it will also tell you at a glance if these functions are included in the functionality that you have already mapped. So if you are working on a particular task it’s an easy way to know if you need to read and understand that function or not. It also helps to give you a good idea of what your code coverage is.
If I click on one of the AppMap pins, I can open the code object in the AppMap, if the function was executed in multiple AppMaps, I’ll get the code picker to choose which AppMap to open.
By clicking on the event, I’ll be taken directly to that specific event handling that request.
Another alternative to using the AppMap pin in your source code is to use a command called “Open code object in AppMap”.
To get here in VS Code open the command palette.
Shift + Command + P
Ctrl + Shift + P
I can then search for the
UsersController#show function - if it’s in a single AppMap I’ll get taken directly to that AppMap. If it exists in more than one you’ll get the quick picker to choose which one you want.
Next step: AppMap Analysis