diff --git a/CHANGELOG.md b/CHANGELOG.md index c3196d7ad3..95b4e13c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add `CheckInUtils.withCheckIn` which abstracts away some of the manual check-ins complexity ([#2959](https://github.com/getsentry/sentry-java/pull/2959)) - Add `@SentryCaptureExceptionParameter` annotation which captures exceptions passed into an annotated method ([#2764](https://github.com/getsentry/sentry-java/pull/2764)) - This can be used to replace `Sentry.captureException` calls in `@ExceptionHandler` of a `@ControllerAdvice` +- Add `ServerWebExchange` to `Hint` for WebFlux as `WEBFLUX_EXCEPTION_HANDLER_EXCHANGE` ([#2977](https://github.com/getsentry/sentry-java/pull/2977)) ## 6.30.0 diff --git a/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/SentryWebExceptionHandler.java b/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/SentryWebExceptionHandler.java index 3310b2d879..24439cd0e9 100644 --- a/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/SentryWebExceptionHandler.java +++ b/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/SentryWebExceptionHandler.java @@ -1,5 +1,6 @@ package io.sentry.spring.jakarta.webflux; +import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_REQUEST; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_RESPONSE; @@ -58,6 +59,7 @@ public SentryWebExceptionHandler(final @NotNull IHub hub) { hint.set(WEBFLUX_EXCEPTION_HANDLER_REQUEST, serverWebExchange.getRequest()); hint.set( WEBFLUX_EXCEPTION_HANDLER_RESPONSE, serverWebExchange.getResponse()); + hint.set(WEBFLUX_EXCEPTION_HANDLER_EXCHANGE, serverWebExchange); hub.captureEvent(event, hint); } diff --git a/sentry-spring/src/main/java/io/sentry/spring/webflux/SentryWebExceptionHandler.java b/sentry-spring/src/main/java/io/sentry/spring/webflux/SentryWebExceptionHandler.java index 08832bd648..98d3855a04 100644 --- a/sentry-spring/src/main/java/io/sentry/spring/webflux/SentryWebExceptionHandler.java +++ b/sentry-spring/src/main/java/io/sentry/spring/webflux/SentryWebExceptionHandler.java @@ -1,5 +1,6 @@ package io.sentry.spring.webflux; +import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_REQUEST; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_RESPONSE; @@ -47,6 +48,7 @@ public SentryWebExceptionHandler(final @NotNull IHub hub) { final Hint hint = new Hint(); hint.set(WEBFLUX_EXCEPTION_HANDLER_REQUEST, serverWebExchange.getRequest()); hint.set(WEBFLUX_EXCEPTION_HANDLER_RESPONSE, serverWebExchange.getResponse()); + hint.set(WEBFLUX_EXCEPTION_HANDLER_EXCHANGE, serverWebExchange); hub.captureEvent(event, hint); } diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index a1fd9b2afa..1caf917a47 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -2594,6 +2594,7 @@ public final class io/sentry/TypeCheckHint { public static final field SPRING_REQUEST_INTERCEPTOR_RESPONSE Ljava/lang/String; public static final field SPRING_RESOLVER_REQUEST Ljava/lang/String; public static final field SPRING_RESOLVER_RESPONSE Ljava/lang/String; + public static final field WEBFLUX_EXCEPTION_HANDLER_EXCHANGE Ljava/lang/String; public static final field WEBFLUX_EXCEPTION_HANDLER_REQUEST Ljava/lang/String; public static final field WEBFLUX_EXCEPTION_HANDLER_RESPONSE Ljava/lang/String; public static final field WEBFLUX_FILTER_REQUEST Ljava/lang/String; diff --git a/sentry/src/main/java/io/sentry/TypeCheckHint.java b/sentry/src/main/java/io/sentry/TypeCheckHint.java index 3c66307602..e9d219c385 100644 --- a/sentry/src/main/java/io/sentry/TypeCheckHint.java +++ b/sentry/src/main/java/io/sentry/TypeCheckHint.java @@ -97,6 +97,9 @@ public final class TypeCheckHint { "webFluxExceptionHandler:response"; /** Used for Spring WebFlux exception handler. */ public static final String WEBFLUX_EXCEPTION_HANDLER_REQUEST = "webFluxExceptionHandler:request"; + /** Used for Spring WebFlux exception handler. */ + public static final String WEBFLUX_EXCEPTION_HANDLER_EXCHANGE = + "webFluxExceptionHandler:exchange"; /** Used for Spring WebFlux filter breadcrumbs. */ public static final String WEBFLUX_FILTER_RESPONSE = "webFluxFilter:response";