spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

HttpClientCustomizer function no access to micrometer tracing context

Open M-Whitaker opened this issue 1 year ago • 5 comments

Describe the bug When creating a http client logger I have found that the trace & span id are not propagated for certain methods.

Sample start.spring.io micrometer tracing & spring cloud gateway

@Bean
  public HttpClientCustomizer httpClientResolverCustomizer(HttpClientLogger httpClientLogger) {
    return httpClient ->
        httpClient
            .doAfterRequest((req, conn) -> logRequest(req, httpClientLogger))
            .doAfterResponseSuccess((res, conn) -> logResponse(res, httpClientLogger));
  }
2023-10-03T23:00:31,971 INFO  [reactor-http-nio-6][app,651c8effe9d86a59bad37df2b701910e,728be67b030f67cf] HttpClientLogger: Sending Request [GET] to [http://localhost/path/to/example] with headers [{}]
2023-10-03T23:00:32,853 INFO  [reactor-http-nio-6][app,,] HttpClientLogger: Received Response [200] from Request to [GET http://localhost/path/to/example] with response headers [{}], duration [N/A]ms

M-Whitaker avatar Oct 03 '23 21:10 M-Whitaker