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-keycloak</module>
|
||||||
<module>spring-boot-kotlin</module>
|
<module>spring-boot-kotlin</module>
|
||||||
<module>spring-boot-logging-log4j2</module>
|
<module>spring-boot-logging-log4j2</module>
|
||||||
|
<module>spring-boot-management</module>
|
||||||
<module>spring-boot-mvc</module>
|
<module>spring-boot-mvc</module>
|
||||||
<module>spring-boot-mvc-birt</module>
|
<module>spring-boot-mvc-birt</module>
|
||||||
<module>spring-boot-ops</module>
|
<module>spring-boot-ops</module>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.baeldung.spring.boot.management.trace;
|
package com.baeldung.spring.boot.management.trace;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
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.HttpTrace;
|
||||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||||
@ -11,23 +11,18 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public class CustomTraceRepository implements HttpTraceRepository {
|
public class CustomTraceRepository implements HttpTraceRepository {
|
||||||
|
|
||||||
List<HttpTrace> traces = new ArrayList<>(1);
|
AtomicReference<HttpTrace> lastTrace = new AtomicReference<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HttpTrace> findAll() {
|
public List<HttpTrace> findAll() {
|
||||||
synchronized (this.traces) {
|
return Collections.singletonList(lastTrace.get());
|
||||||
return Collections.unmodifiableList(new ArrayList<>(this.traces));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(HttpTrace trace) {
|
public void add(HttpTrace trace) {
|
||||||
if ("GET".equals(trace.getRequest()
|
if ("GET".equals(trace.getRequest()
|
||||||
.getMethod())) {
|
.getMethod())) {
|
||||||
synchronized (this.traces) {
|
lastTrace.set(trace);
|
||||||
traces.clear();
|
|
||||||
traces.add(trace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
management.endpoints.web.exposure.include=httptrace
|
management.endpoints.web.exposure.include=httptrace
|
||||||
management.trace.http.include=REQUEST_HEADERS
|
management.trace.http.include=RESPONSE_HEADERS
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user