-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/rz/compose-compile-only
- Loading branch information
Showing
8 changed files
with
145 additions
and
28 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
25 changes: 25 additions & 0 deletions
25
.../sentry-samples-spring-boot-webflux/src/main/java/io/sentry/samples/spring/boot/Todo.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,25 @@ | ||
package io.sentry.samples.spring.boot; | ||
|
||
public class Todo { | ||
private final Long id; | ||
private final String title; | ||
private final boolean completed; | ||
|
||
public Todo(Long id, String title, boolean completed) { | ||
this.id = id; | ||
this.title = title; | ||
this.completed = completed; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public boolean isCompleted() { | ||
return completed; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...mples-spring-boot-webflux/src/main/java/io/sentry/samples/spring/boot/TodoController.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,26 @@ | ||
package io.sentry.samples.spring.boot; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RestController | ||
public class TodoController { | ||
private final WebClient webClient; | ||
|
||
public TodoController(WebClient webClient) { | ||
this.webClient = webClient; | ||
} | ||
|
||
@GetMapping("/todo-webclient/{id}") | ||
Mono<Todo> todoWebClient(@PathVariable Long id) { | ||
return webClient | ||
.get() | ||
.uri("https://jsonplaceholder.typicode.com/todos/{id}", id) | ||
.retrieve() | ||
.bodyToMono(Todo.class) | ||
.map(response -> response); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...pring-jakarta/src/main/java/io/sentry/spring/jakarta/webflux/AbstractSentryWebFilter.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,52 @@ | ||
package io.sentry.spring.jakarta.webflux; | ||
|
||
import com.jakewharton.nopen.annotation.Open; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.http.server.reactive.ServerHttpRequest; | ||
import org.springframework.http.server.reactive.ServerHttpResponse; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import org.springframework.web.server.WebFilter; | ||
import org.springframework.web.server.WebFilterChain; | ||
|
||
import io.sentry.Breadcrumb; | ||
import io.sentry.Hint; | ||
import io.sentry.IHub; | ||
import io.sentry.Sentry; | ||
import static io.sentry.TypeCheckHint.WEBFLUX_FILTER_REQUEST; | ||
import static io.sentry.TypeCheckHint.WEBFLUX_FILTER_RESPONSE; | ||
import io.sentry.util.Objects; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** Manages {@link io.sentry.Scope} in Webflux request processing. */ | ||
@ApiStatus.Experimental | ||
public abstract class AbstractSentryWebFilter implements WebFilter { | ||
private final @NotNull SentryRequestResolver sentryRequestResolver; | ||
public static final String SENTRY_HUB_KEY = "sentry-hub"; | ||
|
||
public AbstractSentryWebFilter(final @NotNull IHub hub) { | ||
Objects.requireNonNull(hub, "hub is required"); | ||
this.sentryRequestResolver = new SentryRequestResolver(hub); | ||
} | ||
|
||
protected void doFinally(final @NotNull IHub requestHub) { | ||
requestHub.popScope(); | ||
} | ||
|
||
protected void doFirst(final @NotNull ServerWebExchange serverWebExchange, final @NotNull IHub requestHub) { | ||
serverWebExchange.getAttributes().put(SENTRY_HUB_KEY, requestHub); | ||
requestHub.pushScope(); | ||
final ServerHttpRequest request = serverWebExchange.getRequest(); | ||
final ServerHttpResponse response = serverWebExchange.getResponse(); | ||
|
||
final Hint hint = new Hint(); | ||
hint.set(WEBFLUX_FILTER_REQUEST, request); | ||
hint.set(WEBFLUX_FILTER_RESPONSE, response); | ||
final String methodName = | ||
request.getMethod() != null ? request.getMethod().name() : "unknown"; | ||
requestHub.addBreadcrumb(Breadcrumb.http(request.getURI().toString(), methodName), hint); | ||
requestHub.configureScope( | ||
scope -> scope.setRequest(sentryRequestResolver.resolveSentryRequest(request))); | ||
} | ||
} |
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