# HTTP request end-to-end trace

HTTP Request End-to-End Tracing is a way to trace the entire end-to-end chain of HTTP requests within a gadget

## Function overview

When using [tt.request](https://open.feishu.cn/document/uYjL24iN/uIDMx4iMwEjLyATM), [tt.uploadFile](https://open.feishu.cn/document/uYjL24iN/uYDMx4iNwEjL2ATM), or [tt.downloadFile](https://open.feishu.cn/document/uYjL24iN/ucDMx4yNwEjL3ATM) in a gadget, the engine generates a unique request ID and sets it in the request header (`x-request-id`, `x-tt-logid`) before sending it to the server.

In the `SuccessCallback`, `FailCallback`, and `Result` of the above interfaces, a `trace` field is added with the request ID as its value.

## Notes

- Feishu client version 4.7 and above support HTTP Request End-to-End Tracing.

- `x-request-id` and `x-tt-logid` are reserved headers for gadget. Using them may cause overwritten content in the header.

## Use cases

- Use Case 1: For backend services that receive requests from gadget, utilize the `x-request-id` from the header as context for diagnostics and end-to-end tracing.

- Use Case 2: For gadget business purposes, include the returned `trace` in self-built network request tracking or logs for diagnostics and end-to-end tracing.

- Use Case 3: When issues occur, perform request ID queries and diagnostics based on the client's logs, tracking points, business logs, tracking points, or backend logs, tracking points.