- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Description
Unlike WebClient, the new RestClient does not propagate tracing headers (e.g., traceId, spanId) automatically when using Micrometer Tracing.
Expected Behavior
When Spring Boot Observability (Micrometer Tracing) is enabled, RestClient should automatically inject the tracing headers, just like WebClient.
Currently, developers must manually add tracing headers to every request, either by:
- Manually adding headers to each request:
RestClient restClient = RestClient.create(); restClient.get() .uri("https://api.example.com") .header("traceparent", "12345") .header("x-span-id", "67890") .retrieve() .body(String.class); 
- Using a custom ClientHttpRequestInterceptor, which requires additional setup.
Motivation
Many Spring developers are migrating from RestTemplate to RestClient because it is its official replacement. However, RestTemplate users often expect automatic observability/tracing, which is currently missing in RestClient.
WebClient provides this functionality out-of-the-box when Micrometer Tracing is enabled. RestClient should offer similar behavior to maintain consistency across Spring's HTTP clients.
Proposal
- Automatically inject tracing headers (traceparent,x-span-id, etc.) when Spring Boot Observability (Micrometer Tracing) is enabled.
- Provide a way to customize or disable this feature if needed.