This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
MainEventProcessor.java
75 lines (61 loc) · 2.46 KB
/
MainEventProcessor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package io.sentry.core;
import static io.sentry.core.ILogger.logIfNotNull;
import io.sentry.core.hints.Cached;
import io.sentry.core.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
@ApiStatus.Internal
public final class MainEventProcessor implements EventProcessor {
private final SentryOptions options;
private final SentryThreadFactory sentryThreadFactory;
private final SentryExceptionFactory sentryExceptionFactory;
MainEventProcessor(final SentryOptions options) {
this.options = Objects.requireNonNull(options, "The SentryOptions is required.");
SentryStackTraceFactory sentryStackTraceFactory =
new SentryStackTraceFactory(options.getInAppExcludes(), options.getInAppIncludes());
sentryExceptionFactory = new SentryExceptionFactory(sentryStackTraceFactory);
sentryThreadFactory = new SentryThreadFactory(sentryStackTraceFactory);
}
MainEventProcessor(
final SentryOptions options,
final SentryThreadFactory sentryThreadFactory,
final SentryExceptionFactory sentryExceptionFactory) {
this.options = Objects.requireNonNull(options, "The SentryOptions is required.");
this.sentryThreadFactory =
Objects.requireNonNull(sentryThreadFactory, "The SentryThreadFactory is required.");
this.sentryExceptionFactory =
Objects.requireNonNull(sentryExceptionFactory, "The SentryExceptionFactory is required.");
}
@Override
public SentryEvent process(SentryEvent event, @Nullable Object hint) {
if (event.getPlatform() == null) {
// this actually means JVM related.
event.setPlatform("java");
}
Throwable throwable = event.getThrowable();
if (throwable != null) {
event.setExceptions(sentryExceptionFactory.getSentryExceptions(throwable));
}
if (!(hint instanceof Cached)) {
processNonCachedEvent(event);
} else {
logIfNotNull(
options.getLogger(),
SentryLevel.DEBUG,
"Event was cached so not applying data relevant to the current app execution/version: %s",
event.getEventId());
}
return event;
}
private void processNonCachedEvent(SentryEvent event) {
if (event.getRelease() == null) {
event.setRelease(options.getRelease());
}
if (event.getEnvironment() == null) {
event.setEnvironment(options.getEnvironment());
}
if (event.getThreads() == null) {
event.setThreads(sentryThreadFactory.getCurrentThreads());
}
}
}