Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sentry raven-java user context

Tags:

java

sentry

raven

How can I set the user context with the sentry raven-java client?

I've tried adding a user_email tag, and adding user_email to the MDC. They both work as expecting, with the tag going to tags, and MDC going to additional data, but neither sets the sentry user context.

I also use sentry with javascript, and with raven-js, this works great:

Raven.setUserContext({
    email: '',
    id: ''
});

Is there a java equivalent?

like image 609
Alden Avatar asked Sep 18 '14 17:09

Alden


1 Answers

Seems can't send user information directly by logback. You can look at the implementation from raven-java:

protected Event buildEvent(ILoggingEvent iLoggingEvent) {
    EventBuilder eventBuilder = new EventBuilder()
            .withTimestamp(new Date(iLoggingEvent.getTimeStamp()))
            .withMessage(iLoggingEvent.getFormattedMessage())
            .withLogger(iLoggingEvent.getLoggerName())
            .withLevel(formatLevel(iLoggingEvent.getLevel()))
            .withExtra(THREAD_NAME, iLoggingEvent.getThreadName());
    ......
}

User info is send by: withSentryInterface(new UserInterface(...)), however what I see this implement only contains code for: StackTraceInterface and MessageInterface. I think you can add one by your self.

like image 139
daisydanngo Avatar answered Nov 16 '22 17:11

daisydanngo