7. API Development with Observability

Updated 2 months ago by Rahul Lahiri

In this section, we will select a sample request from the API Catalog, choose the execution flow configuration, and send the request to the service in the IDE.

Select request from API catalog

We have included some example requests for the movieinfo service to get you started. Pick a request to send to the movieinfo service from the API catalog.

  • Click on the API catalog icon on the left nav bar. From the API catalog, you can access all stored API requests, whether they are coming from test suites (golden sets), or from requests captured from your CI tests, or from collections created by engineers.
  • Select Golden from the Source dropdown, and then select the SampleCollection collection.
  • From the list of services, select movieinfo. From the list of APIs, select minfo/listmovies. The stored requests for the API will be shown in the Requests table.
  • Select one or more of the requests in the API table by clicking on the checkboxes, and then click the View button. Once you click the View button, each request selected will open a tab in the API editor.
  • Each tab shows a trace of the stored request consisting of:
    • The request to the API
    • The response from the API
    • All the egress requests from the service to upstream services
    • The responses from the upstream services
    Click on any of the egress requests in the trace to view the complete details of the request and the corresponding response.

Setup Environment to Run Request

Start service in IDE

The exact process will depend on your IDE.

Example: Eclipse IDE: Go the Servers tab, right-click on the Tomcat server, and clicks on Start.

Select target for request

Configure API Studio to send requests to service in IDE by selecting the localhost environment from the environment dropdown.

Select egress request destinations

  • Select the DevCluster egress request configuration from the proxy settings dropdown.
  • Make sure that all egress requests are configured to use the dev cluster and not use mocks. If any of the services are configured to be mocked, change the configuration by unchecking the Mock box for the service.

Send request to service in IDE

Click the Run button to send the request to the service in the IDE. After the request executes, the results will be populated in the right-hand pane in the tab.

How to read the results

The window is divided into two parts. The left-hand side is the trace for the stored request. The right-hand side is the trace for the test request.

  1. Full details of all the requests and responses in the trace for both API requests. Clicking through the requests in the trace provides complete observability of the request execution at the ingress and egress boundaries of the service for the API.
  2. A side-by-side as well as a diff view of the requests and responses in the trace, making it easy to spot changes.
  3. A trace of the ingress and egress requests sorted by the order of execution. Each trace in the API Studio includes all available information about the request to the API, egress requests and corresponding responses, and the response from API in the IDE, making it easy to understand the flow of the code execution for the request. The ability to diff any of requests or responses makes it easy to spot changes in API behavior quickly.
For the movieinfo/listmovies API request, the first time you run the request after starting up the tomcat server in the IDE, you will see two additional egress requests: restsql/initialize and restsql/health. These requests are issued only the first time the API is run after a cold start of the server in the IDE. On subsequent requests, you will not see these egress requests.

Congratulations! You have run your first request from the API Studio!

Next steps

Next, we will step through an example of how developers can leverage API Studio for auto-creating mocks during development.

How did we do?