Skip to content

Commit 93eb5a9

Browse files
authored
Merge branch '8.x.x' into feat/remove-traceheaders-method
2 parents 66fcaf7 + 6101b73 commit 93eb5a9

File tree

40 files changed

+172
-138
lines changed

40 files changed

+172
-138
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- This will reduce the number of spans created by the SDK
1010
- `options.experimental.sessionReplay.errorSampleRate` was renamed to `options.experimental.sessionReplay.onErrorSampleRate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
1111
- Manifest option `io.sentry.session-replay.error-sample-rate` was renamed to `io.sentry.session-replay.on-error-sample-rate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
12+
- Replace `synchronized` methods and blocks with `ReentrantLock` (`AutoClosableReentrantLock`) ([#3715](https://github.com/getsentry/sentry-java/pull/3715))
13+
- If you are subclassing any Sentry classes, please check if the parent class used `synchronized` before. Please make sure to use the same lock object as the parent class in that case.
1214

1315
### Features
1416

@@ -41,6 +43,10 @@
4143
- Honor ignored span origins in `SentryTracer.startChild` ([#3704](https://github.com/getsentry/sentry-java/pull/3704))
4244
- Add `enable-spotlight` and `spotlight-connection-url` to external options and check if spotlight is enabled when deciding whether to inspect an OpenTelemetry span for connecting to splotlight ([#3709](https://github.com/getsentry/sentry-java/pull/3709))
4345

46+
### Behavioural Changes
47+
48+
- (Android) Replace thread id with kernel thread id in span data ([#3706](https://github.com/getsentry/sentry-java/pull/3706))
49+
4450
### Dependencies
4551

4652
- Bump OpenTelemetry to 1.41.0, OpenTelemetry Java Agent to 2.7.0 and Semantic Conventions to 1.25.0 ([#3668](https://github.com/getsentry/sentry-java/pull/3668))

sentry-android-core/api/sentry-android-core.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ public final class io/sentry/android/core/ViewHierarchyEventProcessor : io/sentr
399399
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
400400
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
401401
public static fun snapshotViewHierarchy (Landroid/app/Activity;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;
402-
public static fun snapshotViewHierarchy (Landroid/app/Activity;Ljava/util/List;Lio/sentry/util/thread/IMainThreadChecker;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;
402+
public static fun snapshotViewHierarchy (Landroid/app/Activity;Ljava/util/List;Lio/sentry/util/thread/IThreadChecker;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;
403403
public static fun snapshotViewHierarchy (Landroid/view/View;)Lio/sentry/protocol/ViewHierarchy;
404404
public static fun snapshotViewHierarchy (Landroid/view/View;Ljava/util/List;)Lio/sentry/protocol/ViewHierarchy;
405-
public static fun snapshotViewHierarchyAsData (Landroid/app/Activity;Lio/sentry/util/thread/IMainThreadChecker;Lio/sentry/ISerializer;Lio/sentry/ILogger;)[B
405+
public static fun snapshotViewHierarchyAsData (Landroid/app/Activity;Lio/sentry/util/thread/IThreadChecker;Lio/sentry/ISerializer;Lio/sentry/ILogger;)[B
406406
}
407407

408408
public final class io/sentry/android/core/cache/AndroidEnvelopeCache : io/sentry/cache/EnvelopeCache {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public final class ActivityBreadcrumbsIntegration
2929
private boolean enabled;
3030
private final @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();
3131

32+
// TODO check if locking is even required at all for lifecycle methods
3233
public ActivityBreadcrumbsIntegration(final @NotNull Application application) {
3334
this.application = Objects.requireNonNull(application, "Application is required");
3435
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io.sentry.ISentryLifecycleToken;
77
import io.sentry.MeasurementUnit;
88
import io.sentry.SentryLevel;
9-
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
9+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
1010
import io.sentry.protocol.MeasurementValue;
1111
import io.sentry.protocol.SentryId;
1212
import io.sentry.util.AutoClosableReentrantLock;
@@ -224,7 +224,7 @@ public void stop() {
224224

225225
private void runSafelyOnUiThread(final Runnable runnable, final String tag) {
226226
try {
227-
if (AndroidMainThreadChecker.getInstance().isMainThread()) {
227+
if (AndroidThreadChecker.getInstance().isMainThread()) {
228228
runnable.run();
229229
} else {
230230
handler.post(

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,13 @@ public void onActivityPaused(final @NotNull Activity activity) {
478478

479479
@Override
480480
public void onActivityStopped(final @NotNull Activity activity) {
481-
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
482-
// no-op
483-
}
481+
// no-op (acquire lock if this no longer is no-op)
484482
}
485483

486484
@Override
487485
public void onActivitySaveInstanceState(
488486
final @NotNull Activity activity, final @NotNull Bundle outState) {
489-
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
490-
// no-op
491-
}
487+
// no-op (acquire lock if this no longer is no-op)
492488
}
493489

494490
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import io.sentry.android.core.internal.gestures.AndroidViewGestureTargetLocator;
2121
import io.sentry.android.core.internal.modules.AssetsModulesLoader;
2222
import io.sentry.android.core.internal.util.AndroidConnectionStatusProvider;
23-
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
23+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
2424
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
2525
import io.sentry.android.core.performance.AppStartMetrics;
2626
import io.sentry.android.fragment.FragmentLifecycleIntegration;
@@ -212,7 +212,7 @@ static void initializeIntegrationsAndProcessors(
212212
options.setViewHierarchyExporters(viewHierarchyExporters);
213213
}
214214

215-
options.setMainThreadChecker(AndroidMainThreadChecker.getInstance());
215+
options.setThreadChecker(AndroidThreadChecker.getInstance());
216216
if (options.getPerformanceCollectors().isEmpty()) {
217217
options.addPerformanceCollector(new AndroidMemoryCollector());
218218
options.addPerformanceCollector(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import io.sentry.Integration;
88
import io.sentry.SentryLevel;
99
import io.sentry.SentryOptions;
10-
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
10+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
1111
import io.sentry.util.Objects;
1212
import java.io.Closeable;
1313
import java.io.IOException;
@@ -58,7 +58,7 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
5858
try {
5959
Class.forName("androidx.lifecycle.DefaultLifecycleObserver");
6060
Class.forName("androidx.lifecycle.ProcessLifecycleOwner");
61-
if (AndroidMainThreadChecker.getInstance().isMainThread()) {
61+
if (AndroidThreadChecker.getInstance().isMainThread()) {
6262
addObserver(scopes);
6363
} else {
6464
// some versions of the androidx lifecycle-process require this to be executed on the main
@@ -127,7 +127,7 @@ public void close() throws IOException {
127127
if (watcher == null) {
128128
return;
129129
}
130-
if (AndroidMainThreadChecker.getInstance().isMainThread()) {
130+
if (AndroidThreadChecker.getInstance().isMainThread()) {
131131
removeObserver();
132132
} else {
133133
// some versions of the androidx lifecycle-process require this to be executed on the main

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
@@ -11,7 +11,7 @@
1111
import io.sentry.SentryEvent;
1212
import io.sentry.SentryLevel;
1313
import io.sentry.SentryReplayEvent;
14-
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
14+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
1515
import io.sentry.android.core.performance.AppStartMetrics;
1616
import io.sentry.android.core.performance.TimeSpan;
1717
import io.sentry.protocol.App;
@@ -214,7 +214,7 @@ private void setThreads(final @NotNull SentryEvent event, final @NotNull Hint hi
214214
final boolean isHybridSDK = HintUtils.isFromHybridSdk(hint);
215215

216216
for (final SentryThread thread : event.getThreads()) {
217-
final boolean isMainThread = AndroidMainThreadChecker.getInstance().isMainThread(thread);
217+
final boolean isMainThread = AndroidThreadChecker.getInstance().isMainThread(thread);
218218

219219
// TODO: Fix https://github.com/getsentry/team-mobile/issues/47
220220
if (thread.isCurrent() == null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static SentryId captureEnvelope(
196196
deleteCurrentSessionFile(
197197
options,
198198
// should be sync if going to crash or already not a main thread
199-
!maybeStartNewSession || !scopes.getOptions().getMainThreadChecker().isMainThread());
199+
!maybeStartNewSession || !scopes.getOptions().getThreadChecker().isMainThread());
200200
if (maybeStartNewSession) {
201201
scopes.startSession();
202202
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static io.sentry.android.core.ActivityLifecycleIntegration.APP_START_WARM;
55
import static io.sentry.android.core.ActivityLifecycleIntegration.UI_LOAD_OP;
66

7-
import android.os.Looper;
87
import io.sentry.EventProcessor;
98
import io.sentry.Hint;
109
import io.sentry.ISentryLifecycleToken;
@@ -14,6 +13,7 @@
1413
import io.sentry.SpanDataConvention;
1514
import io.sentry.SpanId;
1615
import io.sentry.SpanStatus;
16+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
1717
import io.sentry.android.core.performance.ActivityLifecycleTimeSpan;
1818
import io.sentry.android.core.performance.AppStartMetrics;
1919
import io.sentry.android.core.performance.TimeSpan;
@@ -321,7 +321,7 @@ private static SentrySpan timeSpanToSentrySpan(
321321
final @NotNull String operation) {
322322

323323
final Map<String, Object> defaultSpanData = new HashMap<>(2);
324-
defaultSpanData.put(SpanDataConvention.THREAD_ID, Looper.getMainLooper().getThread().getId());
324+
defaultSpanData.put(SpanDataConvention.THREAD_ID, AndroidThreadChecker.mainThreadSystemId);
325325
defaultSpanData.put(SpanDataConvention.THREAD_NAME, "main");
326326

327327
defaultSpanData.put(SpanDataConvention.CONTRIBUTES_TTID, true);

0 commit comments

Comments
 (0)