RestClient dosens не обрабатывайте идентификатор трассировки в моем приложении Spring Boot 3JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 RestClient dosens не обрабатывайте идентификатор трассировки в моем приложении Spring Boot 3

Сообщение Anonymous »

Я мигрировал с resttemplate до restclient в моем приложении Spring Boot 3. Но теперь у меня есть проблема с идентификатором трассировки: идентификатор сквозной операции, в которой проходила эта конкретная общая операция. RestClientConfig :

Код: Выделить всё

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.support.RestClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;

import com.example.clients.BeClient;

@Configuration
public class RestClientConfig {

@Value("${api.url}")
private String apiUrl;

@Bean
public BeClient beClient() {

RestClient restClient = RestClient.builder()
.baseUrl(apiUrl)
.build();
var restClientAdapter = RestClientAdapter.create(restClient);
var httpServiceProxyFactory = HttpServiceProxyFactory.builderFor(restClientAdapter).build();
return httpServiceProxyFactory.createClient(BeClient.class);

}

}
class beclient :

Код: Выделить всё

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;

import com.example.dtos.HelloWorldDto;

@HttpExchange
public interface BeClient {

@GetExchange("/message/{id}")
HelloWorldDto findById(@PathVariable("id") Long id);

}
file application.properties :

Код: Выделить всё

logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
logs fe :
для Fe Service Track Id Cress IS 678d0ddf7a804137440ac3007174d797 .

Код: Выделить всё

2025-01-19 15:36:15.397
2025-01-19T14:36:15.397Z  INFO 1 --- [fe] [http-nio-8080-exec-1] [fe,678d0ddf7a804137440ac3007174d797,440ac3007174d797]c.e.controllers.HelloWorldController     : Called FE method HelloWorldController.findById()
2025-01-19 15:35:47.974
2025-01-19T14:35:47.974Z  INFO 1 --- [fe] [http-nio-8080-exec-1] [fe,,]o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2025-01-19 15:35:47.972
2025-01-19T14:35:47.972Z  INFO 1 --- [fe] [http-nio-8080-exec-1] [fe,,]o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
logs be :
Для Be Service Track Id Im Im Im Im Im IS 678d0ddf07b239da05ec3e7febcb5842 .

Код: Выделить всё

2025-01-19 15:36:15.431
2025-01-19T14:36:15.431Z  INFO 1 --- [be] [http-nio-8081-exec-4] [be,678d0ddf07b239da05ec3e7febcb5842,05ec3e7febcb5842]c.e.controllers.HelloWorldController     : Called BE method HelloWorldController.helloWorld() for id 1
2025-01-19 15:35:57.771
2025-01-19T14:35:57.771Z  INFO 1 --- [be] [http-nio-8081-exec-1] [be,,]o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2025-01-19 15:35:57.770
2025-01-19T14:35:57.770Z  INFO 1 --- [be] [http-nio-8081-exec-1] [be,,]o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
исходный код
Ссылка на репозиторий GIT с исходным кодом: https://github.com/wisniewskikr/chrisbl ... ntобразное и использование Spress> Spress
hase in spress
hase in jas resmary 3.4.1. Есть идеи, как я могу решить эту проблему?

Подробнее здесь: https://stackoverflow.com/questions/793 ... pplication
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»