-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Sending errors in Spring WebFlux integration
- Loading branch information
1 parent
9f87477
commit 5f52d18
Showing
11 changed files
with
165 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
sentry-spring/src/main/java/io/sentry/spring/webflux/SentryReactor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.sentry.spring.webflux; | ||
|
||
import io.sentry.IHub; | ||
import io.sentry.Sentry; | ||
import java.util.function.Consumer; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import reactor.core.publisher.Signal; | ||
|
||
@ApiStatus.Experimental | ||
public final class SentryReactor { | ||
|
||
/** | ||
* Takes the Sentry {@link IHub} associated with the HTTP request and sets it on current thread | ||
* for the time of executing {@link Consumer} given by parameter. | ||
* | ||
* @param consumer - the consumer to execute | ||
* @param <T> type of signal | ||
* @return a consumer of signal | ||
*/ | ||
public static <T> @NotNull Consumer<Signal<T>> withSentry(final @NotNull Consumer<T> consumer) { | ||
return signal -> { | ||
if (!signal.isOnNext()) return; | ||
final IHub currentHub = Sentry.getCurrentHub(); | ||
final IHub contextViewHub = | ||
signal.getContextView().getOrDefault(SentryWebFilter.HUB_REACTOR_CONTEXT_ATTRIBUTE, null); | ||
if (contextViewHub != null) { | ||
Sentry.setCurrentHub(contextViewHub); | ||
try { | ||
consumer.accept(signal.get()); | ||
} finally { | ||
Sentry.setCurrentHub(currentHub); | ||
} | ||
} else { | ||
consumer.accept(signal.get()); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
sentry-spring/src/main/java/io/sentry/spring/webflux/SentryScheduleHook.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.