Skip to content

Commit

Permalink
Merge pull request #26 from agorapulse/chore/yet-another-scope-handling
Browse files Browse the repository at this point in the history
not using withScope for filter handling
  • Loading branch information
musketyr committed May 6, 2022
2 parents 292abc9 + e03b0b5 commit 7d6c6b5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import io.sentry.IHub;
import org.reactivestreams.Publisher;

import java.util.concurrent.atomic.AtomicReference;

@Filter("/**")
public class SentryFilter implements HttpServerFilter {

Expand All @@ -49,13 +47,16 @@ public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, Server
return Flowable
.just(request)
.switchMap(r -> {
AtomicReference<Publisher<MutableHttpResponse<?>>> responsePublisher = new AtomicReference<>();
hub.withScope(scope -> {
hub.pushScope();
hub.configureScope(scope -> {
scope.addEventProcessor(new MicronautRequestEventProcessor(request));
scope.addBreadcrumb(Breadcrumb.http(request.getUri().toString(), request.getMethodName()));
responsePublisher.set(chain.proceed(r));
});
return responsePublisher.get();
try {
return chain.proceed(request);
} finally {
hub.popScope();
}
});
}

Expand Down

0 comments on commit 7d6c6b5

Please sign in to comment.