From 36a40d026896a9328c88ae1374557d47923c92fc Mon Sep 17 00:00:00 2001 From: Utkarsh Srivastava Date: Tue, 10 Oct 2023 07:54:07 +0000 Subject: [PATCH 1/3] Added ServerWebExchange as Hint property --- .../spring/jakarta/webflux/SentryWebExceptionHandler.java | 3 +++ .../io/sentry/spring/webflux/SentryWebExceptionHandler.java | 2 ++ sentry/src/main/java/io/sentry/TypeCheckHint.java | 2 ++ 3 files changed, 7 insertions(+) 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..a84bbf612f 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 @@ -2,6 +2,7 @@ import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_REQUEST; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_RESPONSE; +import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import io.sentry.Hint; import io.sentry.IHub; @@ -58,6 +59,8 @@ 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..1d578e9b2f 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 @@ -2,6 +2,7 @@ import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_REQUEST; import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_RESPONSE; +import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import io.sentry.Hint; import io.sentry.IHub; @@ -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/src/main/java/io/sentry/TypeCheckHint.java b/sentry/src/main/java/io/sentry/TypeCheckHint.java index 3c66307602..e2d8f0dbdb 100644 --- a/sentry/src/main/java/io/sentry/TypeCheckHint.java +++ b/sentry/src/main/java/io/sentry/TypeCheckHint.java @@ -97,6 +97,8 @@ 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"; From e48b42dabcdd911912334f99049bcaf095073c71 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 10 Oct 2023 10:13:59 +0200 Subject: [PATCH 2/3] format and api --- .../spring/jakarta/webflux/SentryWebExceptionHandler.java | 5 ++--- .../io/sentry/spring/webflux/SentryWebExceptionHandler.java | 2 +- sentry/api/sentry.api | 1 + sentry/src/main/java/io/sentry/TypeCheckHint.java | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) 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 a84bbf612f..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,8 +1,8 @@ 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; -import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import io.sentry.Hint; import io.sentry.IHub; @@ -59,8 +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); + 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 1d578e9b2f..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,8 +1,8 @@ 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; -import static io.sentry.TypeCheckHint.WEBFLUX_EXCEPTION_HANDLER_EXCHANGE; import io.sentry.Hint; import io.sentry.IHub; 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 e2d8f0dbdb..e9d219c385 100644 --- a/sentry/src/main/java/io/sentry/TypeCheckHint.java +++ b/sentry/src/main/java/io/sentry/TypeCheckHint.java @@ -98,7 +98,8 @@ public final class TypeCheckHint { /** 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"; + 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"; From eed651abc04bd3caab1cd3fe42236f3693dd4b28 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 10 Oct 2023 10:20:01 +0200 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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