Skip to content
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

Re-apply 7.x.x changes #4124

Merged
merged 9 commits into from
Jan 30, 2025
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
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@
- Remove `java.lang.ClassNotFoundException` debug logs when searching for OpenTelemetry marker classes ([#4091](https://github.com/getsentry/sentry-java/pull/4091))
- There was up to three of these, one for `io.sentry.opentelemetry.agent.AgentMarker`, `io.sentry.opentelemetry.agent.AgentlessMarker` and `io.sentry.opentelemetry.agent.AgentlessSpringMarker`.
- These were not indicators of something being wrong but rather the SDK looking at what is available at runtime to configure itself accordingly.
- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))

### Behavioural Changes

- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
- Drop `TempSensorBreadcrumbsIntegration`
- Drop `PhoneStateBreadcrumbsIntegration`
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`

Current list of the broadcast events can be found [here](https://github.com/getsentry/sentry-java/blob/9b8dc0a844d10b55ddeddf55d278c0ab0f86421c/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L131-L153). If you'd like to subscribe for more events, consider overriding the `SystemEventsBreadcrumbsIntegration` as follows:

```kotlin
SentryAndroid.init(context) { options ->
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
}
```

If you would like to keep some of the default broadcast events as breadcrumbs, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues/new).
- Set mechanism `type` to `suppressed` for suppressed exceptions ([#4125](https://github.com/getsentry/sentry-java/pull/4125))
- This helps to distinguish an exceptions cause from any suppressed exceptions in the Sentry UI

Expand Down Expand Up @@ -330,6 +352,68 @@ If you have been using `8.0.0-rc.4` of the Java SDK, here's the new changes that
- We are planning to improve this in the future but opted for this fix first.
- Fix swallow NDK loadLibrary errors ([#4082](https://github.com/getsentry/sentry-java/pull/4082))

## 7.21.0

### Fixes

- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))

### Behavioural Changes

- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
- Drop `TempSensorBreadcrumbsIntegration`
- Drop `PhoneStateBreadcrumbsIntegration`
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`

Current list of the broadcast events can be found [here](https://github.com/getsentry/sentry-java/blob/9b8dc0a844d10b55ddeddf55d278c0ab0f86421c/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L131-L153). If you'd like to subscribe for more events, consider overriding the `SystemEventsBreadcrumbsIntegration` as follows:

```kotlin
SentryAndroid.init(context) { options ->
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
}
```

If you would like to keep some of the default broadcast events as breadcrumbs, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues/new).

## 7.21.0-beta.1

### Fixes

- Do not instrument File I/O operations if tracing is disabled ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Do not instrument User Interaction multiple times ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Speed up view traversal to find touched target in `UserInteractionIntegration` ([#4051](https://github.com/getsentry/sentry-java/pull/4051))
- Reduce IPC/Binder calls performed by the SDK ([#4058](https://github.com/getsentry/sentry-java/pull/4058))

### Behavioural Changes

- Reduce the number of broadcasts the SDK is subscribed for ([#4052](https://github.com/getsentry/sentry-java/pull/4052))
- Drop `TempSensorBreadcrumbsIntegration`
- Drop `PhoneStateBreadcrumbsIntegration`
- Reduce number of broadcasts in `SystemEventsBreadcrumbsIntegration`

Current list of the broadcast events can be found [here](https://github.com/getsentry/sentry-java/blob/9b8dc0a844d10b55ddeddf55d278c0ab0f86421c/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L131-L153). If you'd like to subscribe for more events, consider overriding the `SystemEventsBreadcrumbsIntegration` as follows:

```kotlin
SentryAndroid.init(context) { options ->
options.integrations.removeAll { it is SystemEventsBreadcrumbsIntegration }
options.integrations.add(SystemEventsBreadcrumbsIntegration(context, SystemEventsBreadcrumbsIntegration.getDefaultActions() + listOf(/* your custom actions */)))
}
```

If you would like to keep some of the default broadcast events as breadcrumbs, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues/new).

## 7.20.1

### Behavioural Changes

- The user ip-address is now only set to `"{{auto}}"` if sendDefaultPii is enabled ([#4071](https://github.com/getsentry/sentry-java/pull/4071))
- This change gives you control over IP address collection directly on the client


## 7.20.0

### Features
Expand Down
27 changes: 13 additions & 14 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public final class io/sentry/android/core/DeviceInfoUtil {
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
public fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
public fun getTotalMemory ()Ljava/lang/Long;
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
public static fun resetInstance ()V
}
Expand Down Expand Up @@ -248,12 +249,6 @@ public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sen
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
public fun getOrder ()Ljava/lang/Long;
Expand Down Expand Up @@ -382,14 +377,7 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
public fun close ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
public static fun getDefaultActions ()Ljava/util/List;
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

Expand Down Expand Up @@ -535,3 +523,14 @@ public class io/sentry/android/core/performance/WindowContentChangedCallback : i
public fun onContentChanged ()V
}

public final class io/sentry/android/core/util/AndroidLazyEvaluator {
public fun <init> (Lio/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator;)V
public fun getValue (Landroid/content/Context;)Ljava/lang/Object;
public fun resetValue ()V
public fun setValue (Ljava/lang/Object;)V
}

public abstract interface class io/sentry/android/core/util/AndroidLazyEvaluator$AndroidEvaluator {
public abstract fun evaluate (Landroid/content/Context;)Ljava/lang/Object;
}

Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ static void installDefaultIntegrations(
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));
options.addIntegration(
new NetworkBreadcrumbsIntegration(context, buildInfoProvider, options.getLogger()));
options.addIntegration(new TempSensorBreadcrumbsIntegration(context));
options.addIntegration(new PhoneStateBreadcrumbsIntegration(context));
if (isReplayAvailable) {
final ReplayIntegration replay =
new ReplayIntegration(context, CurrentDateProvider.getInstance());
Expand All @@ -326,8 +324,8 @@ private static void readDefaultOptionValues(
final @NotNull SentryAndroidOptions options,
final @NotNull Context context,
final @NotNull BuildInfoProvider buildInfoProvider) {
final PackageInfo packageInfo =
ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
final @Nullable PackageInfo packageInfo =
ContextUtils.getPackageInfo(context, buildInfoProvider);
if (packageInfo != null) {
// Sets App's release if not set by Manifest
if (options.getRelease() == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.sentry.android.core;

import static android.content.Context.ACTIVITY_SERVICE;
import static java.util.concurrent.TimeUnit.SECONDS;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Process;
Expand Down Expand Up @@ -258,9 +256,12 @@ public void bindTransaction(final @NotNull ITransaction transaction) {
transactionsCounter = 0;

String totalMem = "0";
ActivityManager.MemoryInfo memInfo = getMemInfo();
if (memInfo != null) {
totalMem = Long.toString(memInfo.totalMem);
final @Nullable Long memory =
(options instanceof SentryAndroidOptions)
? DeviceInfoUtil.getInstance(context, (SentryAndroidOptions) options).getTotalMemory()
: null;
if (memory != null) {
totalMem = Long.toString(memory);
}
String[] abis = Build.SUPPORTED_ABIS;

Expand Down Expand Up @@ -327,27 +328,6 @@ public void close() {
}
}

/**
* Get MemoryInfo object representing the memory state of the application.
*
* @return MemoryInfo object representing the memory state of the application
*/
private @Nullable ActivityManager.MemoryInfo getMemInfo() {
try {
ActivityManager actManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
if (actManager != null) {
actManager.getMemoryInfo(memInfo);
return memInfo;
}
logger.log(SentryLevel.INFO, "Error getting MemoryInfo.");
return null;
} catch (Throwable e) {
logger.log(SentryLevel.ERROR, "Error getting MemoryInfo.", e);
return null;
}
}

@TestOnly
int getTransactionsCounter() {
return transactionsCounter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,13 @@ private void setApp(final @NotNull SentryBaseEvent event, final @NotNull Object
if (app == null) {
app = new App();
}
app.setAppName(ContextUtils.getApplicationName(context, options.getLogger()));
app.setAppName(ContextUtils.getApplicationName(context));
// TODO: not entirely correct, because we define background ANRs as not the ones of
// IMPORTANCE_FOREGROUND, but this doesn't mean the app was in foreground when an ANR happened
// but it's our best effort for now. We could serialize AppState in theory.
app.setInForeground(!isBackgroundAnr(hint));

final PackageInfo packageInfo =
ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
final PackageInfo packageInfo = ContextUtils.getPackageInfo(context, buildInfoProvider);
if (packageInfo != null) {
app.setAppIdentifier(packageInfo.packageName);
}
Expand Down Expand Up @@ -597,8 +596,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
try {
final ContextUtils.SideLoadedInfo sideLoadedInfo =
ContextUtils.retrieveSideLoadedInfo(context, options.getLogger(), buildInfoProvider);

DeviceInfoUtil.getInstance(context, options).getSideLoadedInfo();
if (sideLoadedInfo != null) {
final @NotNull Map<String, String> tags = sideLoadedInfo.asTags();
for (Map.Entry<String, String> entry : tags.entrySet()) {
Expand Down Expand Up @@ -667,7 +665,8 @@ private void setDevice(final @NotNull SentryBaseEvent event) {

private void mergeOS(final @NotNull SentryBaseEvent event) {
final OperatingSystem currentOS = event.getContexts().getOperatingSystem();
final OperatingSystem androidOS = getOperatingSystem();
final OperatingSystem androidOS =
DeviceInfoUtil.getInstance(context, options).getOperatingSystem();

// make Android OS the main OS using the 'os' key
event.getContexts().setOperatingSystem(androidOS);
Expand All @@ -683,20 +682,5 @@ private void mergeOS(final @NotNull SentryBaseEvent event) {
event.getContexts().put(osNameKey, currentOS);
}
}

private @NotNull OperatingSystem getOperatingSystem() {
OperatingSystem os = new OperatingSystem();
os.setName("Android");
os.setVersion(Build.VERSION.RELEASE);
os.setBuild(Build.DISPLAY);

try {
os.setKernelVersion(ContextUtils.getKernelVersion(options.getLogger()));
} catch (Throwable e) {
options.getLogger().log(SentryLevel.ERROR, "Error getting OperatingSystem.", e);
}

return os;
}
// endregion
}
Loading
Loading