Skip to content

Commit cddb1f0

Browse files
authored
Merge branch 'main' into feat/experimental-otel-global-hub-mode
2 parents 0ba317a + 6df3ba5 commit cddb1f0

File tree

12 files changed

+34
-16
lines changed

12 files changed

+34
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Update profile chunk rate limit and client report ([#4353](https://github.com/getsentry/sentry-java/pull/4353))
8+
9+
## 8.9.0
10+
511
### Features
612

713
- Add `SentryWrapper.wrapRunnable` to wrap `Runnable` for use with Sentry ([#4332](https://github.com/getsentry/sentry-java/pull/4332))
@@ -24,6 +30,7 @@
2430
### Improvements
2531

2632
- Make user interaction tracing faster and do fewer allocations ([#4347](https://github.com/getsentry/sentry-java/pull/4347))
33+
- Pre-load modules on a background thread upon SDK init ([#4348](https://github.com/getsentry/sentry-java/pull/4348))
2734

2835
## 8.8.0
2936

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ org.gradle.workers.max=2
1414
android.useAndroidX=true
1515

1616
# Release information
17-
versionName=8.8.0
17+
versionName=8.9.0
1818

1919
# Override the SDK name on native crashes on Android
2020
sentryAndroidSdkName=sentry.native.android

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private void start() {
178178
final @Nullable RateLimiter rateLimiter = scopes.getRateLimiter();
179179
if (rateLimiter != null
180180
&& (rateLimiter.isActiveForCategory(All)
181-
|| rateLimiter.isActiveForCategory(DataCategory.ProfileChunk))) {
181+
|| rateLimiter.isActiveForCategory(DataCategory.ProfileChunkUi))) {
182182
logger.log(SentryLevel.WARNING, "SDK is rate limited. Stopping profiler.");
183183
// Let's stop and reset profiler id, as the profile is now broken anyway
184184
stop(false);
@@ -385,7 +385,7 @@ public int getRootSpanCounter() {
385385
public void onRateLimitChanged(@NotNull RateLimiter rateLimiter) {
386386
// We stop the profiler as soon as we are rate limited, to avoid the performance overhead
387387
if (rateLimiter.isActiveForCategory(All)
388-
|| rateLimiter.isActiveForCategory(DataCategory.ProfileChunk)) {
388+
|| rateLimiter.isActiveForCategory(DataCategory.ProfileChunkUi)) {
389389
logger.log(SentryLevel.WARNING, "SDK is rate limited. Stopping profiler.");
390390
stop(false);
391391
}

sentry-android-core/src/main/java/io/sentry/android/core/internal/modules/AssetsModulesLoader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public final class AssetsModulesLoader extends ModulesLoader {
2121
public AssetsModulesLoader(final @NotNull Context context, final @NotNull ILogger logger) {
2222
super(logger);
2323
this.context = ContextUtils.getApplicationContext(context);
24+
25+
// pre-load modules on a bg thread to avoid doing so on the main thread in case of a crash/error
26+
//noinspection Convert2MethodRef
27+
new Thread(() -> getOrLoadModules()).start();
2428
}
2529

2630
@Override

sentry-android-core/src/test/java/io/sentry/android/core/AndroidContinuousProfilerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class AndroidContinuousProfilerTest {
505505
fun `profiler stops when rate limited`() {
506506
val profiler = fixture.getSut()
507507
val rateLimiter = mock<RateLimiter>()
508-
whenever(rateLimiter.isActiveForCategory(DataCategory.ProfileChunk)).thenReturn(true)
508+
whenever(rateLimiter.isActiveForCategory(DataCategory.ProfileChunkUi)).thenReturn(true)
509509

510510
profiler.startProfiler(ProfileLifecycle.MANUAL, fixture.mockTracesSampler)
511511
assertTrue(profiler.isRunning)
@@ -521,7 +521,7 @@ class AndroidContinuousProfilerTest {
521521
fun `profiler does not start when rate limited`() {
522522
val profiler = fixture.getSut()
523523
val rateLimiter = mock<RateLimiter>()
524-
whenever(rateLimiter.isActiveForCategory(DataCategory.ProfileChunk)).thenReturn(true)
524+
whenever(rateLimiter.isActiveForCategory(DataCategory.ProfileChunkUi)).thenReturn(true)
525525
whenever(fixture.scopes.rateLimiter).thenReturn(rateLimiter)
526526

527527
// If the SDK is rate limited, the profiler should never start

sentry/api/sentry.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public final class io/sentry/DataCategory : java/lang/Enum {
354354
public static final field Error Lio/sentry/DataCategory;
355355
public static final field Monitor Lio/sentry/DataCategory;
356356
public static final field Profile Lio/sentry/DataCategory;
357-
public static final field ProfileChunk Lio/sentry/DataCategory;
357+
public static final field ProfileChunkUi Lio/sentry/DataCategory;
358358
public static final field Replay Lio/sentry/DataCategory;
359359
public static final field Security Lio/sentry/DataCategory;
360360
public static final field Session Lio/sentry/DataCategory;

sentry/src/main/java/io/sentry/DataCategory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public enum DataCategory {
1212
Attachment("attachment"),
1313
Monitor("monitor"),
1414
Profile("profile"),
15-
ProfileChunk("profile_chunk"),
15+
ProfileChunkUi("profile_chunk_ui"),
1616
Transaction("transaction"),
1717
Replay("replay"),
1818
Span("span"),

sentry/src/main/java/io/sentry/SentryItemType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum SentryItemType implements JsonSerializable {
1515
Attachment("attachment"),
1616
Transaction("transaction"),
1717
Profile("profile"),
18-
ProfileChunk("profile_chunk"),
18+
ProfileChunk("profile_chunk_ui"),
1919
ClientReport("client_report"),
2020
ReplayEvent("replay_event"),
2121
ReplayRecording("replay_recording"),

sentry/src/main/java/io/sentry/clientreport/ClientReportRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private DataCategory categoryFromItemType(SentryItemType itemType) {
166166
return DataCategory.Profile;
167167
}
168168
if (SentryItemType.ProfileChunk.equals(itemType)) {
169-
return DataCategory.ProfileChunk;
169+
return DataCategory.ProfileChunkUi;
170170
}
171171
if (SentryItemType.Attachment.equals(itemType)) {
172172
return DataCategory.Attachment;

sentry/src/main/java/io/sentry/internal/modules/ModulesLoader.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.sentry.internal.modules;
22

33
import io.sentry.ILogger;
4+
import io.sentry.ISentryLifecycleToken;
45
import io.sentry.SentryLevel;
6+
import io.sentry.util.AutoClosableReentrantLock;
57
import java.io.BufferedReader;
68
import java.io.IOException;
79
import java.io.InputStream;
@@ -21,18 +23,23 @@ public abstract class ModulesLoader implements IModulesLoader {
2123

2224
public static final String EXTERNAL_MODULES_FILENAME = "sentry-external-modules.txt";
2325
protected final @NotNull ILogger logger;
24-
private @Nullable Map<String, String> cachedModules = null;
26+
27+
private final @NotNull AutoClosableReentrantLock modulesLock = new AutoClosableReentrantLock();
28+
private volatile @Nullable Map<String, String> cachedModules = null;
2529

2630
public ModulesLoader(final @NotNull ILogger logger) {
2731
this.logger = logger;
2832
}
2933

3034
@Override
3135
public @Nullable Map<String, String> getOrLoadModules() {
32-
if (cachedModules != null) {
33-
return cachedModules;
36+
if (cachedModules == null) {
37+
try (final @NotNull ISentryLifecycleToken ignored = modulesLock.acquire()) {
38+
if (cachedModules == null) {
39+
cachedModules = loadModules();
40+
}
41+
}
3442
}
35-
cachedModules = loadModules();
3643
return cachedModules;
3744
}
3845

0 commit comments

Comments
 (0)