Skip to content

Commit 59c4e8d

Browse files
Do not resolve hostname in Android integration.
1 parent 028e5a9 commit 59c4e8d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class SentryAndroidOptions extends SentryOptions {
3939
public SentryAndroidOptions() {
4040
setSentryClientName(BuildConfig.SENTRY_ANDROID_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
4141
setSdkVersion(createSdkVersion());
42+
setAttachServerName(false);
4243
}
4344

4445
private @NotNull SdkVersion createSdkVersion() {

sentry/src/main/java/io/sentry/MainEventProcessor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ public final class MainEventProcessor implements EventProcessor {
2929
private final @NotNull SentryOptions options;
3030
private final @NotNull SentryThreadFactory sentryThreadFactory;
3131
private final @NotNull SentryExceptionFactory sentryExceptionFactory;
32-
private final @NotNull HostnameCache hostnameCache;
32+
private final @Nullable HostnameCache hostnameCache;
3333

3434
MainEventProcessor(final @NotNull SentryOptions options) {
35-
this(options, new HostnameCache());
35+
this(options, options.isAttachServerName() ? new HostnameCache() : null);
3636
}
3737

3838
MainEventProcessor(
39-
final @NotNull SentryOptions options, final @NotNull HostnameCache hostnameCache) {
39+
final @NotNull SentryOptions options, final @Nullable HostnameCache hostnameCache) {
4040
this.options = Objects.requireNonNull(options, "The SentryOptions is required.");
41-
this.hostnameCache = Objects.requireNonNull(hostnameCache, "The HostnameCache is required");
41+
this.hostnameCache = hostnameCache;
4242

4343
final SentryStackTraceFactory sentryStackTraceFactory =
4444
new SentryStackTraceFactory(
@@ -148,7 +148,7 @@ private void processNonCachedEvent(final @NotNull SentryEvent event) {
148148
event.getUser().setIpAddress(DEFAULT_IP_ADDRESS);
149149
}
150150
}
151-
if (options.isAttachServerName() && event.getServerName() == null) {
151+
if (options.isAttachServerName() && hostnameCache != null && event.getServerName() == null) {
152152
event.setServerName(hostnameCache.getHostname());
153153
}
154154
}

0 commit comments

Comments
 (0)