Skip to content

Commit 8ef6ac5

Browse files
committed
Merge branch 'feat/cache-tracing-wrappers' into feat/cache-tracing-option
2 parents 5f39eb5 + 6e4ede5 commit 8ef6ac5

File tree

74 files changed

+1348
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1348
-500
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Changelog
22

3-
## Unreleased
3+
## 8.34.0
44

55
### Features
66

7+
- Add scope-level attributes API ([#5118](https://github.com/getsentry/sentry-java/pull/5118)) via ([#5148](https://github.com/getsentry/sentry-java/pull/5148))
8+
- Automatically include scope attributes in logs and metrics ([#5120](https://github.com/getsentry/sentry-java/pull/5120))
9+
- New APIs are `Sentry.setAttribute`, `Sentry.setAttributes`, `Sentry.removeAttribute`
10+
- Support collections and arrays in attribute type inference ([#5124](https://github.com/getsentry/sentry-java/pull/5124))
11+
- Add support for `SENTRY_SAMPLE_RATE` environment variable / `sample-rate` property ([#5112](https://github.com/getsentry/sentry-java/pull/5112))
712
- Create `sentry-opentelemetry-otlp` and `sentry-opentelemetry-otlp-spring` modules for combining OpenTelemetry SDK OTLP export with Sentry SDK ([#5100](https://github.com/getsentry/sentry-java/pull/5100))
813
- OpenTelemetry is configured to send spans to Sentry directly using an OTLP endpoint.
914
- Sentry only uses trace and span ID from OpenTelemetry (via `OpenTelemetryOtlpEventProcessor`) but will not send spans through OpenTelemetry nor use OpenTelemetry `Context` for `Scopes` propagation.
@@ -27,10 +32,19 @@
2732
<meta-data android:name="io.sentry.screenshot.mask-all-text" android:value="true" />
2833
<meta-data android:name="io.sentry.screenshot.mask-all-images" android:value="true" />
2934
```
35+
- The `ManifestMetaDataReader` now read the `DIST` ([#5107](https://github.com/getsentry/sentry-java/pull/5107))
3036

3137
### Fixes
3238

39+
- Fix attribute type detection for `Long`, `Short`, `Byte`, `BigInteger`, `AtomicInteger`, and `AtomicLong` being incorrectly inferred as `double` instead of `integer` ([#5122](https://github.com/getsentry/sentry-java/pull/5122))
40+
- Remove `AndroidRuntimeManager` StrictMode relaxation to prevent ANRs during SDK init ([#5127](https://github.com/getsentry/sentry-java/pull/5127))
41+
- **IMPORTANT:** StrictMode violations may appear again in debug builds. This is intentional to prevent ANRs in production releases.
3342
- Fix crash when unregistering `SystemEventsBroadcastReceiver` with try-catch block. ([#5106](https://github.com/getsentry/sentry-java/pull/5106))
43+
- Use `peekDecorView` instead of `getDecorView` in `SentryGestureListener` to avoid forcing view hierarchy construction ([#5134](https://github.com/getsentry/sentry-java/pull/5134))
44+
- Log an actionable error message when Relay returns HTTP 413 (Content Too Large) ([#5115](https://github.com/getsentry/sentry-java/pull/5115))
45+
- Also switch the client report discard reason for all HTTP 4xx/5xx errors (except 429) from `network_error` to `send_error`
46+
- Trim DSN string before parsing to avoid `URISyntaxException` caused by trailing whitespace ([#5113](https://github.com/getsentry/sentry-java/pull/5113))
47+
- Reduce allocations and bytecode instructions during `Sentry.init` ([#5135](https://github.com/getsentry/sentry-java/pull/5135))
3448

3549
### Dependencies
3650

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android.useAndroidX=true
1212
android.experimental.lint.version=8.9.0
1313

1414
# Release information
15-
versionName=8.33.0
15+
versionName=8.34.0
1616

1717
# Override the SDK name on native crashes on Android
1818
sentryAndroidSdkName=sentry.native.android

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.sentry.android.core.internal.modules.AssetsModulesLoader;
3333
import io.sentry.android.core.internal.util.AndroidConnectionStatusProvider;
3434
import io.sentry.android.core.internal.util.AndroidCurrentDateProvider;
35-
import io.sentry.android.core.internal.util.AndroidRuntimeManager;
3635
import io.sentry.android.core.internal.util.AndroidThreadChecker;
3736
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
3837
import io.sentry.android.core.performance.AppStartMetrics;
@@ -123,7 +122,6 @@ static void loadDefaultAndMetadataOptions(
123122
options.setDefaultScopeType(ScopeType.CURRENT);
124123
options.setOpenTelemetryMode(SentryOpenTelemetryMode.OFF);
125124
options.setDateProvider(new SentryAndroidDateProvider());
126-
options.setRuntimeManager(new AndroidRuntimeManager());
127125
options.getLogs().setLoggerBatchProcessorFactory(new AndroidLoggerBatchProcessorFactory());
128126
options.getMetrics().setMetricsBatchProcessorFactory(new AndroidMetricsBatchProcessorFactory());
129127

@@ -135,13 +133,11 @@ static void loadDefaultAndMetadataOptions(
135133

136134
ManifestMetadataReader.applyMetadata(finalContext, options, buildInfoProvider);
137135

138-
options.setCacheDirPath(
139-
options
140-
.getRuntimeManager()
141-
.runWithRelaxedPolicy(() -> getCacheDir(finalContext).getAbsolutePath()));
136+
options.setCacheDirPath(getCacheDir(finalContext).getAbsolutePath());
142137

143138
readDefaultOptionValues(options, finalContext, buildInfoProvider);
144139
AppState.getInstance().registerLifecycleObserver(options);
140+
options.activate();
145141
}
146142

147143
@TestOnly
@@ -200,7 +196,7 @@ static void initializeIntegrationsAndProcessors(
200196
final @NotNull AppStartMetrics appStartMetrics = AppStartMetrics.getInstance();
201197

202198
if (options.getModulesLoader() instanceof NoOpModulesLoader) {
203-
options.setModulesLoader(new AssetsModulesLoader(context, options.getLogger()));
199+
options.setModulesLoader(new AssetsModulesLoader(context, options));
204200
}
205201
if (options.getDebugMetaLoader() instanceof NoOpDebugMetaLoader) {
206202
options.setDebugMetaLoader(new AssetsDebugMetaLoader(context, options.getLogger()));
@@ -470,8 +466,7 @@ private static void readDefaultOptionValues(
470466

471467
if (options.getDistinctId() == null) {
472468
try {
473-
options.setDistinctId(
474-
options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context)));
469+
options.setDistinctId(Installation.id(context));
475470
} catch (RuntimeException e) {
476471
options.getLogger().log(SentryLevel.ERROR, "Could not generate distinct Id.", e);
477472
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
564564

565565
private @Nullable String getDeviceId() {
566566
try {
567-
return options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context));
567+
return Installation.id(context);
568568
} catch (Throwable e) {
569569
options.getLogger().log(SentryLevel.ERROR, "Error getting installationId.", e);
570570
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
174174

175175
// userId should be set even if event is Cached as the userId is static and won't change anyway.
176176
if (user.getId() == null) {
177-
user.setId(options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context)));
177+
user.setId(Installation.id(context));
178178
}
179179
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
180180
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
@@ -372,7 +372,7 @@ private void setAppExtras(final @NotNull App app, final @NotNull Hint hint) {
372372
*/
373373
public @NotNull User getDefaultUser(final @NotNull Context context) {
374374
final @NotNull User user = new User();
375-
user.setId(options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context)));
375+
user.setId(Installation.id(context));
376376
return user;
377377
}
378378

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,21 @@ private void setDeviceIO(
232232
// this way of getting the size of storage might be problematic for storages bigger than 2GB
233233
// check the use of
234234
// https://developer.android.com/reference/java/io/File.html#getFreeSpace%28%29
235-
options
236-
.getRuntimeManager()
237-
.runWithRelaxedPolicy(
238-
() -> {
239-
final @Nullable File dataDir = Environment.getDataDirectory();
240-
if (dataDir != null) {
241-
StatFs internalStorageStat = new StatFs(dataDir.getPath());
242-
device.setStorageSize(getTotalInternalStorage(internalStorageStat));
243-
device.setFreeStorage(getUnusedInternalStorage(internalStorageStat));
244-
}
245-
246-
if (includeExternalStorage) {
247-
final @Nullable File internalStorageFile = context.getExternalFilesDir(null);
248-
final @Nullable StatFs externalStorageStat =
249-
getExternalStorageStat(internalStorageFile);
250-
if (externalStorageStat != null) {
251-
device.setExternalStorageSize(getTotalExternalStorage(externalStorageStat));
252-
device.setExternalFreeStorage(getUnusedExternalStorage(externalStorageStat));
253-
}
254-
}
255-
});
235+
final @Nullable File dataDir = Environment.getDataDirectory();
236+
if (dataDir != null) {
237+
StatFs internalStorageStat = new StatFs(dataDir.getPath());
238+
device.setStorageSize(getTotalInternalStorage(internalStorageStat));
239+
device.setFreeStorage(getUnusedInternalStorage(internalStorageStat));
240+
}
241+
242+
if (includeExternalStorage) {
243+
final @Nullable File internalStorageFile = context.getExternalFilesDir(null);
244+
final @Nullable StatFs externalStorageStat = getExternalStorageStat(internalStorageFile);
245+
if (externalStorageStat != null) {
246+
device.setExternalStorageSize(getTotalExternalStorage(externalStorageStat));
247+
device.setExternalFreeStorage(getUnusedExternalStorage(externalStorageStat));
248+
}
249+
}
256250

257251
if (device.getConnectionType() == null) {
258252
// wifi, ethernet or cellular, null if none
@@ -493,7 +487,7 @@ private Long getUnusedExternalStorage(final @NotNull StatFs stat) {
493487
@Nullable
494488
private String getDeviceId() {
495489
try {
496-
return options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context));
490+
return Installation.id(context);
497491
} catch (Throwable e) {
498492
options.getLogger().log(SentryLevel.ERROR, "Error getting installationId.", e);
499493
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public static Map<String, Object> serializeScope(
102102
}
103103
if (user.getId() == null) {
104104
try {
105-
user.setId(
106-
options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context)));
105+
user.setId(Installation.id(context));
107106
} catch (RuntimeException e) {
108107
logger.log(SentryLevel.ERROR, "Could not retrieve installation ID", e);
109108
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ final class ManifestMetadataReader {
4141
static final String NDK_SCOPE_SYNC_ENABLE = "io.sentry.ndk.scope-sync.enable";
4242
static final String NDK_SDK_NAME = "io.sentry.ndk.sdk-name";
4343
static final String RELEASE = "io.sentry.release";
44+
static final String DIST = "io.sentry.dist";
4445
static final String ENVIRONMENT = "io.sentry.environment";
4546
static final String SDK_NAME = "io.sentry.sdk.name";
4647
static final String SDK_VERSION = "io.sentry.sdk.version";
@@ -273,6 +274,8 @@ static void applyMetadata(
273274

274275
options.setRelease(readString(metadata, logger, RELEASE, options.getRelease()));
275276

277+
options.setDist(readString(metadata, logger, DIST, options.getDist()));
278+
276279
options.setEnvironment(readString(metadata, logger, ENVIRONMENT, options.getEnvironment()));
277280

278281
options.setSessionTrackingIntervalMillis(

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
import io.sentry.SentryOptions;
2121
import io.sentry.TracesSampler;
2222
import io.sentry.TracesSamplingDecision;
23-
import io.sentry.android.core.internal.util.AndroidRuntimeManager;
2423
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
2524
import io.sentry.android.core.performance.AppStartMetrics;
2625
import io.sentry.android.core.performance.TimeSpan;
2726
import io.sentry.util.AutoClosableReentrantLock;
28-
import io.sentry.util.runtime.IRuntimeManager;
2927
import java.io.BufferedReader;
3028
import java.io.File;
3129
import java.io.FileInputStream;
@@ -110,9 +108,7 @@ private void launchAppStartProfiler(final @NotNull AppStartMetrics appStartMetri
110108
return;
111109
}
112110

113-
final @NotNull IRuntimeManager runtimeManager = new AndroidRuntimeManager();
114-
final @NotNull File cacheDir =
115-
runtimeManager.runWithRelaxedPolicy(() -> AndroidOptionsInitializer.getCacheDir(context));
111+
final @NotNull File cacheDir = AndroidOptionsInitializer.getCacheDir(context);
116112
final @NotNull File configFile = new File(cacheDir, APP_START_PROFILING_CONFIG_FILE_NAME);
117113

118114
// No config exists: app start profiling is not enabled

sentry-android-core/src/main/java/io/sentry/android/core/cache/AndroidEnvelopeCache.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ public static boolean hasStartupCrashMarker(final @NotNull SentryOptions options
125125

126126
final File crashMarkerFile = new File(outboxPath, STARTUP_CRASH_MARKER_FILE);
127127
try {
128-
final boolean exists =
129-
options.getRuntimeManager().runWithRelaxedPolicy(() -> crashMarkerFile.exists());
128+
final boolean exists = crashMarkerFile.exists();
130129
if (exists) {
131-
if (!options.getRuntimeManager().runWithRelaxedPolicy(() -> crashMarkerFile.delete())) {
130+
if (!crashMarkerFile.delete()) {
132131
options
133132
.getLogger()
134133
.log(

0 commit comments

Comments
 (0)