Java sdk:ContextManager for non blocking webserver


#1

I have a non blocking web app using vert.x-web, so one thread does not refer to one http request. So i would like to store my context in vert.x’s routingContext, but to do that i have to specify the routingContext anytime i need a sentry context.
So probably the best way would be to just manage sentry contexts manually, and tell sentry about the context any time i add an event. is that possible?


#2

Async context is something I’ve wanted to work on for a while, but haven’t had the time. I think the best solution would be to implement a ContextManager that’s specific to Vert.x. I imagine this might require us changing that interface (to allow for some kind of identifier that is passed around between threads?): https://github.com/getsentry/sentry-java/blob/9e11a3a3c5d099acc7a9ee28304c8f89257f6cdf/sentry/src/main/java/io/sentry/context/ContextManager.java

The fallback would be to manage context yourself, as you said. Right before you send an event you could clear the context, send the event, and then clear the context again:

        Context context = Sentry.getContext();
        context.clear();
        context.addTag("foo", "bar");
        Sentry.capture("send event");
        context.clear();

Brett