Skip to content

[QA] Hardcode integration names #3794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fix potential ANRs due to NDK scope sync ([#3754](https://github.com/getsentry/sentry-java/pull/3754))
- Fix potential ANRs due to NDK System.loadLibrary calls ([#3670](https://github.com/getsentry/sentry-java/pull/3670))
- Fix slow `Log` calls on app startup ([#3793](https://github.com/getsentry/sentry-java/pull/3793))
- Fix slow Integration name parsing ([#3794](https://github.com/getsentry/sentry-java/pull/3794))

## 7.15.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
if (enabled) {
application.registerActivityLifecycleCallbacks(this);
options.getLogger().log(SentryLevel.DEBUG, "ActivityBreadcrumbIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ActivityBreadcrumbs");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio

application.registerActivityLifecycleCallbacks(this);
this.options.getLogger().log(SentryLevel.DEBUG, "ActivityLifecycleIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ActivityLifecycle");
}

private boolean isPerformanceEnabled(final @NotNull SentryAndroidOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void register(final @NotNull IHub hub, final @NotNull SentryAndroidOptio
.log(SentryLevel.DEBUG, "AnrIntegration enabled: %s", options.isAnrEnabled());

if (options.isAnrEnabled()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Anr");
try {
options
.getExecutorService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to start AnrProcessor.", e);
}
options.getLogger().log(SentryLevel.DEBUG, "AnrV2Integration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AnrV2");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
options
.getLogger()
.log(SentryLevel.DEBUG, "AppComponentsBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AppComponentsBreadcrumbs");
} catch (Throwable e) {
this.options.setEnableAppComponentBreadcrumbs(false);
options.getLogger().log(SentryLevel.INFO, e, "ComponentCallbacks2 is not available.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void addObserver(final @NotNull IHub hub) {
try {
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);
options.getLogger().log(SentryLevel.DEBUG, "AppLifecycleIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AppLifecycle");
} catch (Throwable e) {
// This is to handle a potential 'AbstractMethodError' gracefully. The error is triggered in
// connection with conflicting dependencies of the androidx.lifecycle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final void register(final @NotNull IHub hub, final @NotNull SentryOptions
method.invoke(null, args);

this.options.getLogger().log(SentryLevel.DEBUG, "NdkIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Ndk");
} catch (NoSuchMethodException e) {
disableNdkIntegration(this.options);
this.options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void run() {
context, logger, buildInfoProvider, networkCallback);
if (registered) {
logger.log(SentryLevel.DEBUG, "NetworkBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("NetworkBreadcrumbs");
} else {
logger.log(
SentryLevel.DEBUG, "NetworkBreadcrumbsIntegration not installed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void startTelephonyListener(
telephonyManager.listen(listener, android.telephony.PhoneStateListener.LISTEN_CALL_STATE);

options.getLogger().log(SentryLevel.DEBUG, "PhoneStateBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("PhoneStateBreadcrumbs");
} catch (Throwable e) {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ScreenshotEventProcessor(
DEBOUNCE_MAX_EXECUTIONS);

if (options.isAttachScreenshot()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Screenshot");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.sentry.android.core;

import static io.sentry.util.IntegrationUtils.addIntegrationToSdkVersion;

import io.sentry.DataCategory;
import io.sentry.IConnectionStatusProvider;
import io.sentry.IHub;
Expand Down Expand Up @@ -54,6 +56,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
options.getLogger().log(SentryLevel.ERROR, "No cache dir path is defined in options.");
return;
}
addIntegrationToSdkVersion("SendCachedEnvelope");

sendCachedEnvelopes(hub, this.options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void startSystemEventsReceiver(
// registerReceiver can throw SecurityException but it's not documented in the official docs
ContextUtils.registerReceiver(context, options, receiver, filter);
options.getLogger().log(SentryLevel.DEBUG, "SystemEventsBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("SystemEventsBreadcrumbs");
} catch (Throwable e) {
options.setEnableSystemEventBreadcrumbs(false);
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void startSensorListener(final @NotNull SentryOptions options) {
sensorManager.registerListener(this, defaultSensor, SensorManager.SENSOR_DELAY_NORMAL);

options.getLogger().log(SentryLevel.DEBUG, "TempSensorBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("TempSensorBreadcrumbs");
} else {
options.getLogger().log(SentryLevel.INFO, "TYPE_AMBIENT_TEMPERATURE is not available.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
if (isAndroidXAvailable) {
application.registerActivityLifecycleCallbacks(this);
this.options.getLogger().log(SentryLevel.DEBUG, "UserInteractionIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("UserInteraction");
} else {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ViewHierarchyEventProcessor(final @NotNull SentryAndroidOptions options)
DEBOUNCE_MAX_EXECUTIONS);

if (options.isAttachViewHierarchy()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ViewHierarchy");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FragmentLifecycleIntegration(

application.registerActivityLifecycleCallbacks(this)
options.logger.log(DEBUG, "FragmentLifecycleIntegration installed.")
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("FragmentLifecycle")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SentryNavigationListener @JvmOverloads constructor(
private var activeTransaction: ITransaction? = null

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("NavigationListener")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SentryOkHttpInterceptor(
constructor(beforeSpan: BeforeSpanCallback) : this(HubAdapter.getInstance(), beforeSpan)

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("OkHttp")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-okhttp", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class ReplayIntegration(
options.logger.log(INFO, "ComponentCallbacks is not available, orientation changes won't be handled by Session replay", e)
}

addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("Replay")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SentryTimberIntegration(

logger.log(SentryLevel.DEBUG, "SentryTimberIntegration installed.")
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-android-timber", VERSION_NAME)
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("Timber")
}

override fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SentryApolloInterceptor(
constructor(beforeSpan: BeforeSpanCallback) : this(HubAdapter.getInstance(), beforeSpan)

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("Apollo")
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-apollo", BuildConfig.VERSION_NAME)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public open class SentryOkHttpInterceptor(
public constructor(beforeSpan: BeforeSpanCallback) : this(HubAdapter.getInstance(), beforeSpan)

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("OkHttp")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-okhttp", BuildConfig.VERSION_NAME)
}
Expand Down
1 change: 0 additions & 1 deletion sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -5690,7 +5690,6 @@ public final class io/sentry/util/HttpUtils {

public final class io/sentry/util/IntegrationUtils {
public fun <init> ()V
public static fun addIntegrationToSdkVersion (Ljava/lang/Class;)V
public static fun addIntegrationToSdkVersion (Ljava/lang/String;)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
options
.getLogger()
.log(SentryLevel.DEBUG, "SendCachedEventFireAndForgetIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("SendCachedEnvelopeFireAndForget");

sendCachedEnvelopes(hub, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
() -> {
runtime.addShutdownHook(thread);
options.getLogger().log(SentryLevel.DEBUG, "ShutdownHookIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ShutdownHook");
});
} else {
options.getLogger().log(SentryLevel.INFO, "enableShutdownHook is disabled.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
this.options
.getLogger()
.log(SentryLevel.DEBUG, "UncaughtExceptionHandlerIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("UncaughtExceptionHandler");
}
}

Expand Down
10 changes: 0 additions & 10 deletions sentry/src/main/java/io/sentry/util/IntegrationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@

@ApiStatus.Internal
public final class IntegrationUtils {
public static void addIntegrationToSdkVersion(final @NotNull Class<?> clazz) {
final String name =
clazz
.getSimpleName()
.replace("Sentry", "")
.replace("Integration", "")
.replace("Interceptor", "")
.replace("EventProcessor", "");
addIntegrationToSdkVersion(name);
}

public static void addIntegrationToSdkVersion(final @NotNull String name) {
SentryIntegrationPackageStorage.getInstance().addIntegration(name);
Expand Down
Loading