Basic Usage
You can enable the request ID feature using therequestId config option. When set to true, it uses the default configuration (X-Request-Id header and UUID v4 generator).
Production Preset
Theprod preset enables requestId automatically by default:
Custom Configuration
For advanced use cases, you can pass a configuration object instead of a boolean:Options
Log Formatting
When Request ID is enabled, you can output it in your custom log format using the{requestId} token:
Error Responses
If a request fails (e.g. throws an exception), the request ID is still propagated in the response headers (likeX-Request-Id) and is correctly logged in the HTTP error telemetry context, allowing trace correlation for failed requests.