22 Ağustos 2022 Pazartesi

SpringBoot Actuator - Http Trace Endpoint

Giriş
Açıklaması şöyle
We can trace the application requests also using Actuator. But in recent versions of Spring Boot, it is disabled by default. So, we can enable that by adding the below config to application.properties.
management.trace.http.enabled=true
Ayrıca HttpTraceRepository isimli bir bean yaratılması gerekir.

Çıktı görmek için şöyle yaparız
http://localhost:8080/actuator/httptrace

HttpTraceRepository Arayüzü
Açıklaması şöyle.
HTTP Tracing can be enabled by providing a bean of type HttpTraceRepository in your application’s configuration. For convenience, Spring Boot offers an InMemoryHttpTraceRepository that store traces for the last 100 request-response exchanges
Örnek
Şöyle yaparız
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HttpTraceActuatorConfiguration {

  @Bean
  public HttpTraceRepository httpTraceRepository() {
    return new InMemoryHttpTraceRepository();
  }
}




Hiç yorum yok:

Yorum Gönder