Java Code Examples for io.sentry.Sentry#clearContext()

The following examples show how to use io.sentry.Sentry#clearContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SentryHelper.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
public static void captureExceptionContext(String message, Throwable t, Class<?> clazz, String user) {
    final Context context = Sentry.getContext();
    context.setUser(new UserBuilder().setUsername(user).build());
    EventBuilder eventBuilder = new EventBuilder()
            .withMessage(message)
            .withLevel(Event.Level.ERROR)
            .withLogger(clazz.getName())
            .withSentryInterface(new ExceptionInterface(t));
    Sentry.capture(eventBuilder);
    Sentry.clearContext();
}
 
Example 2
Source File: SentryHelper.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
public static void captureMessageContext(String message, Class<?> clazz, String user) {
    final Context context = Sentry.getContext();
    context.setUser(new UserBuilder().setUsername(user).build());
    EventBuilder eventBuilder = new EventBuilder()
            .withMessage(message)
            .withLevel(Event.Level.INFO)
            .withLogger(clazz.getName());

    Sentry.capture(eventBuilder);
    Sentry.clearContext();
}
 
Example 3
Source File: SentryHelper.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
public static void captureMessageErrorContext(String message, Class<?> clazz, String user) {
    final Context context = Sentry.getContext();
    context.setUser(new UserBuilder().setUsername(user).build());
    EventBuilder eventBuilder = new EventBuilder()
            .withMessage(message)
            .withLevel(Event.Level.ERROR)
            .withLogger(clazz.getName());

    Sentry.capture(eventBuilder);
    Sentry.clearContext();
}
 
Example 4
Source File: SentryHelper.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
public static void breadcrumbContext(String breadcrumb, String user) {
    final Context context = Sentry.getContext();
    context.setUser(new UserBuilder().setUsername(user).build());
    context.recordBreadcrumb(
            new BreadcrumbBuilder().setMessage(breadcrumb).build()
    );
    Sentry.clearContext();
}