使用请求跟踪调试 APIDebug your APIs using request tracing

本教程介绍如何检查请求处理,以帮助对 API 进行调试和故障排除。This tutorial describes how to inspect request processing to help you with debugging and troubleshooting your API.

本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 跟踪调用Trace a call

API 检查器

先决条件Prerequisites

跟踪调用Trace a call

API 跟踪

  1. 选择“API”。Select APIs.

  2. 在 API 列表中单击“演示会议 API”。Click Demo Conference API from your API list.

  3. 切换到“测试”选项卡。Switch to the Test tab.

  4. 选择“GetSpeakers”操作。Select GetSpeakers operation.

  5. 请确保包含名为 Ocp-Apim-Trace、值设置为 true 的 HTTP 标头。Make sure to include an HTTP header named Ocp-Apim-Trace with the value set to true.

    Note

    如果 Ocp-Apim-Subscription-Key 未自动填充,可以通过转到开发人员门户并在配置文件页面上公开密钥来检索它。If Ocp-Apim-Subscription-Key is not automatically populated, you can retrieve it by going to the Developer Portal and exposing the keys on the profile page.

  6. 单击“发送”发出 API 调用。Click "Send" to make an API call.

  7. 等待调用完成。Wait for the call to complete.

  8. 在“API 控制台”中转到“跟踪”选项卡。Go to the Trace tab in the API console. 可以单击以下任一链接跳转到详细跟踪信息:“入站”、“后端”或“出站”。You can click any of the following links to jump to detailed trace info: inbound, backend, outbound.

    在“入站”部分,可以看到 API 管理从调用方收到的原始请求,以及应用到该请求的所有策略,包括步骤 2 中添加的 rate-limit 和 set-header 策略。In the inbound section, you see the original request API Management received from the caller and all the policies applied to the request including the rate-limit and set-header policies we added in step 2.

    在“后端”部分,可以看到 API 管理发送到 API 后端的请求以及收到的响应。In the backend section, you see the requests API Management sent to the API backend and the response it received.

    在“出站”部分,可以看到在将响应发回给调用方之前应用到该响应的所有策略。In the outbound section, you see all the policies applied to the response before sending back to the caller.

    Tip

    每个步骤还显示了自 API 管理收到请求以来消逝的时间。Each step also shows the elapsed time since the request is received by API Management.

后续步骤Next steps

在本教程中,你已学习了如何执行以下操作:In this tutorial, you learned how to:

  • 跟踪调用Trace a call

转到下一教程:Advance to the next tutorial: