mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Upgrade to Reactor 2025.0.0-M5 and Micrometer 1.16.0-M1
Includes Netty 4.2.3 Closes gh-35169 Closes gh-35170
This commit is contained in:
@@ -8,9 +8,9 @@ javaPlatform {
|
||||
|
||||
dependencies {
|
||||
api(platform("com.fasterxml.jackson:jackson-bom:2.18.4"))
|
||||
api(platform("io.micrometer:micrometer-bom:1.15.1"))
|
||||
api(platform("io.netty:netty-bom:4.2.2.Final"))
|
||||
api(platform("io.projectreactor:reactor-bom:2025.0.0-M4"))
|
||||
api(platform("io.micrometer:micrometer-bom:1.16.0-M1"))
|
||||
api(platform("io.netty:netty-bom:4.2.3.Final"))
|
||||
api(platform("io.projectreactor:reactor-bom:2025.0.0-M5"))
|
||||
api(platform("io.rsocket:rsocket-bom:1.1.5"))
|
||||
api(platform("org.apache.groovy:groovy-bom:4.0.27"))
|
||||
api(platform("org.apache.logging.log4j:log4j-bom:3.0.0-beta3"))
|
||||
|
||||
+9
-5
@@ -23,6 +23,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import io.micrometer.common.KeyValue;
|
||||
import io.micrometer.common.KeyValues;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -89,12 +90,15 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextualName(ServerRequestObservationContext context) {
|
||||
String httpMethod = context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
|
||||
if (context.getPathPattern() != null) {
|
||||
return "http " + httpMethod + " " + context.getPathPattern();
|
||||
public @Nullable String getContextualName(ServerRequestObservationContext context) {
|
||||
if (context.getCarrier() != null) {
|
||||
String httpMethod = context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
|
||||
if (context.getPathPattern() != null) {
|
||||
return "http " + httpMethod + " " + context.getPathPattern();
|
||||
}
|
||||
return "http " + httpMethod;
|
||||
}
|
||||
return "http " + httpMethod;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-5
@@ -21,6 +21,7 @@ import java.util.Set;
|
||||
|
||||
import io.micrometer.common.KeyValue;
|
||||
import io.micrometer.common.KeyValues;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -87,12 +88,15 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextualName(ServerRequestObservationContext context) {
|
||||
String httpMethod = context.getCarrier().getMethod().name().toLowerCase(Locale.ROOT);
|
||||
if (context.getPathPattern() != null) {
|
||||
return "http " + httpMethod + " " + context.getPathPattern();
|
||||
public @Nullable String getContextualName(ServerRequestObservationContext context) {
|
||||
if (context.getCarrier() != null) {
|
||||
String httpMethod = context.getCarrier().getMethod().name().toLowerCase(Locale.ROOT);
|
||||
if (context.getPathPattern() != null) {
|
||||
return "http " + httpMethod + " " + context.getPathPattern();
|
||||
}
|
||||
return "http " + httpMethod;
|
||||
}
|
||||
return "http " + httpMethod;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+31
-17
@@ -55,19 +55,23 @@ import org.springframework.http.server.observation.ServerRequestObservationConve
|
||||
public class ServerHttpObservationFilter extends OncePerRequestFilter {
|
||||
|
||||
/**
|
||||
* Name of the request attribute holding the {@link ServerRequestObservationContext context} for the current observation.
|
||||
* Name of the request attribute holding the {@link ServerRequestObservationContext} for the current observation.
|
||||
*/
|
||||
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE = ServerHttpObservationFilter.class.getName() + ".context";
|
||||
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE =
|
||||
ServerHttpObservationFilter.class.getName() + ".context";
|
||||
|
||||
private static final ServerRequestObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultServerRequestObservationConvention();
|
||||
private static final String CURRENT_OBSERVATION_ATTRIBUTE =
|
||||
ServerHttpObservationFilter.class.getName() + ".observation";
|
||||
|
||||
private static final String CURRENT_OBSERVATION_ATTRIBUTE = ServerHttpObservationFilter.class.getName() + ".observation";
|
||||
private static final ServerRequestObservationConvention DEFAULT_OBSERVATION_CONVENTION =
|
||||
new DefaultServerRequestObservationConvention();
|
||||
|
||||
|
||||
private final ObservationRegistry observationRegistry;
|
||||
|
||||
private final ServerRequestObservationConvention observationConvention;
|
||||
|
||||
|
||||
/**
|
||||
* Create an {@code HttpRequestsObservationFilter} that records observations
|
||||
* against the given {@link ObservationRegistry}. The default
|
||||
@@ -89,14 +93,6 @@ public class ServerHttpObservationFilter extends OncePerRequestFilter {
|
||||
this.observationConvention = observationConvention;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current {@link ServerRequestObservationContext observation context} from the given request, if available.
|
||||
* @param request the current request
|
||||
* @return the current observation context
|
||||
*/
|
||||
public static Optional<ServerRequestObservationContext> findObservationContext(HttpServletRequest request) {
|
||||
return Optional.ofNullable((ServerRequestObservationContext) request.getAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilterAsyncDispatch() {
|
||||
@@ -150,8 +146,9 @@ public class ServerHttpObservationFilter extends OncePerRequestFilter {
|
||||
Observation observation = (Observation) request.getAttribute(CURRENT_OBSERVATION_ATTRIBUTE);
|
||||
if (observation == null) {
|
||||
ServerRequestObservationContext context = new ServerRequestObservationContext(request, response);
|
||||
observation = ServerHttpObservationDocumentation.HTTP_SERVLET_SERVER_REQUESTS.observation(this.observationConvention,
|
||||
DEFAULT_OBSERVATION_CONVENTION, () -> context, this.observationRegistry).start();
|
||||
observation = ServerHttpObservationDocumentation.HTTP_SERVLET_SERVER_REQUESTS.observation(
|
||||
this.observationConvention, DEFAULT_OBSERVATION_CONVENTION, () -> context, this.observationRegistry)
|
||||
.start();
|
||||
request.setAttribute(CURRENT_OBSERVATION_ATTRIBUTE, observation);
|
||||
if (!observation.isNoop()) {
|
||||
request.setAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE, observation.getContext());
|
||||
@@ -160,14 +157,32 @@ public class ServerHttpObservationFilter extends OncePerRequestFilter {
|
||||
return observation;
|
||||
}
|
||||
|
||||
static @Nullable Throwable unwrapServletException(Throwable ex) {
|
||||
return (ex instanceof ServletException) ? ex.getCause() : ex;
|
||||
|
||||
/**
|
||||
* Get the current {@link ServerRequestObservationContext observation context} from the given request, if available.
|
||||
* @param request the current request
|
||||
* @return the current observation context
|
||||
*/
|
||||
public static Optional<ServerRequestObservationContext> findObservationContext(HttpServletRequest request) {
|
||||
return Optional.ofNullable(
|
||||
(ServerRequestObservationContext) request.getAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE));
|
||||
}
|
||||
|
||||
static @Nullable Throwable fetchException(ServletRequest request) {
|
||||
return (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
|
||||
}
|
||||
|
||||
static Throwable unwrapServletException(Throwable ex) {
|
||||
if (ex instanceof ServletException) {
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause != null) {
|
||||
return cause;
|
||||
}
|
||||
}
|
||||
return ex;
|
||||
}
|
||||
|
||||
|
||||
private static class ObservationAsyncListener implements AsyncListener {
|
||||
|
||||
private final Observation currentObservation;
|
||||
@@ -195,7 +210,6 @@ public class ServerHttpObservationFilter extends OncePerRequestFilter {
|
||||
public void onError(AsyncEvent event) {
|
||||
this.currentObservation.error(unwrapServletException(event.getThrowable()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user