improvements Spring httpTrace + added spring-boot-management to main pom
This commit is contained in:
parent
9e7a60545f
commit
ebfee30bb9
1
pom.xml
1
pom.xml
|
@ -652,6 +652,7 @@
|
|||
<module>spring-boot-keycloak</module>
|
||||
<module>spring-boot-kotlin</module>
|
||||
<module>spring-boot-logging-log4j2</module>
|
||||
<module>spring-boot-management</module>
|
||||
<module>spring-boot-mvc</module>
|
||||
<module>spring-boot-mvc-birt</module>
|
||||
<module>spring-boot-ops</module>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung.spring.boot.management.trace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||
|
@ -11,23 +11,18 @@ import org.springframework.stereotype.Repository;
|
|||
@Repository
|
||||
public class CustomTraceRepository implements HttpTraceRepository {
|
||||
|
||||
List<HttpTrace> traces = new ArrayList<>(1);
|
||||
AtomicReference<HttpTrace> lastTrace = new AtomicReference<>();
|
||||
|
||||
@Override
|
||||
public List<HttpTrace> findAll() {
|
||||
synchronized (this.traces) {
|
||||
return Collections.unmodifiableList(new ArrayList<>(this.traces));
|
||||
}
|
||||
return Collections.singletonList(lastTrace.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(HttpTrace trace) {
|
||||
if ("GET".equals(trace.getRequest()
|
||||
.getMethod())) {
|
||||
synchronized (this.traces) {
|
||||
traces.clear();
|
||||
traces.add(trace);
|
||||
}
|
||||
lastTrace.set(trace);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
management.endpoints.web.exposure.include=httptrace
|
||||
management.trace.http.include=REQUEST_HEADERS
|
||||
management.trace.http.include=RESPONSE_HEADERS
|
||||
|
||||
|
|
Loading…
Reference in New Issue