Part 3: Trace API calls

About the Trace tool

Use the Trace tool for troubleshooting and monitoring API proxies running on Apigee Edge. Trace lets you probe the details of each step through an API proxy flow, view the request and response objects, view response times, and more. The Trace tool lets you review data on how a request changes it is processed by an API proxy. You can see how each policy is performing and how long it takes to execute. By examining the data during debugging, you can see exactly where any problems occur.

Prerequisites for this tutorial

This tutorial assumes that you have competed the first tutorial, where you create an API proxy to access the Yahoo weather API. If you have not yet completed that tutorial, see Part 1: Create your API.

Step 1: Execute and Trace API calls

Trace shows you data from a number of calls taken from live data. Send calls to your weather API to generate the trace data.

In the management UI, click the APIs tab. If the API Platform page is not open, click here.

Click weather in the API Proxies table.

On the weather detail page, click the Trace button to access the Trace page.

On the Trace page, choose the test environment. This will let you set up a trace session on the test environment.

Click Start Trace Session.

The trace session runs for 10 minutes. While the trace session is running, messages are captured from live traffic.

Request your API directly from a Web browser by entering the following URL:

http://{org-name}-{env}.apigee.net/v1/weather/forecastrss?w=12797282

where:

{org-name} is the name of your organization

{env} is the environment, which is either test or prod.

For example:

http://myorg-test.apigee.net/v1/weather/forecastrss?w=12797282

The processing time for each message appears in the Transactions section of the Trace page.

Request the URL from the Trace page itself by entering the URL and clicking Send in the Send Requests section.

You can click Send multiple times to generate as much traffic as you wish.

Click the first transaction in the Transactions section.

The response and request flows of your API call are shown graphically in the Transaction Map section (below the Send Requests section). Below the graphic you can see the request received by your API proxy from the client and the response sent to the client.

Examine the request flow from client to the backend service, and then view the response from the backend service to the client. Click the Next button on the far-right of the window to step through the process.

The first time you select Next you will see the request as it was sent to the Spike Arrest policy.

Click Next until you see the response from the backend service.

At each step you can examine the Phase Details to get more information. In this case, examine the Response Content section so you can see the forecast data that was sent back from the Yahoo weather service. Notice how it is formatted as XML.

Click Next until you see the response from the XML to JSON policy. Notice that the Response Body now contains JSON data.

If you added the Spike Arrest policy, continue to hit the Send button until you generate a rate limit violation.

You will see an HTTP 500 error in the Transactions section of the Trace page. ​If you can't send requests quickly enough to get a 500 response, make sure you set the rate to 1pm in the Spike Arrest policy.

Step 2: Where to next?

Apigee Edge collects information as data passes through it. The data includes API call information (URL, IP, and user ID) latency, errors, and so on. This data is gathered into trend charts and tables throughout the management UI. You can use this data to both monitor the overall health of your API program and the health of individual APIs.