Skip to content

Commit ff4a437

Browse files
committed
Merge branch 'main' into markushi/fix/compose-view-hierarchy-exporter
2 parents 6a69939 + 087248f commit ff4a437

File tree

90 files changed

+1216
-228
lines changed

Some content is hidden

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

90 files changed

+1216
-228
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,38 @@
22

33
## Unreleased
44

5+
### Behavioral Changes
6+
7+
- The Sentry SDK will now crash on startup if mixed versions have been detected ([#4277](https://github.com/getsentry/sentry-java/pull/4277))
8+
- On `Sentry.init` / `SentryAndroid.init` the SDK now checks if all Sentry Java / Android SDK dependencies have the same version.
9+
- While this may seem like a bad idea at first glance, mixing versions of dependencies has a very high chance of causing a crash later. We opted for a controlled crash that's hard to miss.
10+
- Note: This detection only works for new versions of the SDK, so please take this as a reminder to check your SDK version alignment manually when upgrading the SDK to this version and then you should be good.
11+
- The SDK will also print log messages if mixed versions have been detected at a later point. ([#4270](https://github.com/getsentry/sentry-java/pull/4270))
12+
- This takes care of cases missed by the startup check above due to older versions.
13+
514
### Features
615

716
- Increase http timeouts from 5s to 30s to have a better chance of events being delivered without retry ([#4276](https://github.com/getsentry/sentry-java/pull/4276))
17+
- Add `MANIFEST.MF` to Sentry JARs ([#4272](https://github.com/getsentry/sentry-java/pull/4272))
18+
- Retain baggage sample rate/rand values as doubles ([#4279](https://github.com/getsentry/sentry-java/pull/4279))
19+
- Introduce fatal SDK logger ([#4288](https://github.com/getsentry/sentry-java/pull/4288))
20+
- We use this to print out messages when there is a problem that prevents the SDK from working correctly.
21+
- One example for this is when the SDK has been configured with mixed dependency versions where we print out details, which module and version are affected.
822

923
### Fixes
1024

1125
- Do not override user-defined `SentryOptions` ([#4262](https://github.com/getsentry/sentry-java/pull/4262))
1226
- Session Replay: Change bitmap config to `ARGB_8888` for screenshots ([#4282](https://github.com/getsentry/sentry-java/pull/4282))
27+
- The `MANIFEST.MF` of `sentry-opentelemetry-agent` now has `Implementation-Version` set to the raw version ([#4291](https://github.com/getsentry/sentry-java/pull/4291))
28+
- An example value would be `8.6.0`
29+
- The value of the `Sentry-Version-Name` attribute looks like `sentry-8.5.0-otel-2.10.0`
1330
- Fix tags missing for compose view hierarchies ([#4275](https://github.com/getsentry/sentry-java/pull/4275))
1431

32+
### Internal
33+
34+
- Added `platform` to SentryEnvelopeItemHeader ([#4287](https://github.com/getsentry/sentry-java/pull/4287))
35+
- Set `android` platform to ProfileChunk envelope item header
36+
1537
### Dependencies
1638

1739
- Bump Native SDK from v0.8.1 to v0.8.2 ([#4267](https://github.com/getsentry/sentry-java/pull/4267))

buildSrc/src/main/java/Config.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,21 @@ object Config {
251251
val SENTRY_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring"
252252
val SENTRY_SPRING_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring.jakarta"
253253
val SENTRY_SPRING_BOOT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot"
254+
val SENTRY_SPRING_BOOT_STARTER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter"
254255
val SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot.jakarta"
256+
val SENTRY_SPRING_BOOT_STARTER_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter.jakarta"
257+
val SENTRY_OPENTELEMETRY_BOOTSTRAP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.bootstrap"
258+
val SENTRY_OPENTELEMETRY_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.core"
255259
val SENTRY_OPENTELEMETRY_AGENT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agent"
260+
val SENTRY_OPENTELEMETRY_AGENTLESS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless"
261+
val SENTRY_OPENTELEMETRY_AGENTLESS_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless-spring"
262+
val SENTRY_OPENTELEMETRY_AGENTCUSTOMIZATION_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentcustomization"
263+
val SENTRY_OPENFEIGN_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.openfeign"
256264
val SENTRY_APOLLO3_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo3"
257265
val SENTRY_APOLLO4_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo4"
258266
val SENTRY_APOLLO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo"
259267
val SENTRY_GRAPHQL_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql"
268+
val SENTRY_GRAPHQL_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql-core"
260269
val SENTRY_GRAPHQL22_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql22"
261270
val SENTRY_QUARTZ_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.quartz"
262271
val SENTRY_JDBC_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.jdbc"
@@ -265,6 +274,7 @@ object Config {
265274
val SENTRY_COMPOSE_HELPER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.compose.helper"
266275
val SENTRY_OKHTTP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.okhttp"
267276
val SENTRY_REACTOR_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.reactor"
277+
val SENTRY_KOTLIN_EXTENSIONS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.kotlin-extensions"
268278
val group = "io.sentry"
269279
val description = "SDK for sentry.io"
270280
val versionNameProp = "versionName"

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ public final class io/sentry/android/core/AndroidDateUtils {
6363
public static fun getCurrentSentryDateTime ()Lio/sentry/SentryDate;
6464
}
6565

66+
public final class io/sentry/android/core/AndroidFatalLogger : io/sentry/ILogger {
67+
public fun <init> ()V
68+
public fun <init> (Ljava/lang/String;)V
69+
public fun isEnabled (Lio/sentry/SentryLevel;)Z
70+
public fun log (Lio/sentry/SentryLevel;Ljava/lang/String;Ljava/lang/Throwable;)V
71+
public fun log (Lio/sentry/SentryLevel;Ljava/lang/String;[Ljava/lang/Object;)V
72+
public fun log (Lio/sentry/SentryLevel;Ljava/lang/Throwable;Ljava/lang/String;[Ljava/lang/Object;)V
73+
}
74+
6675
public final class io/sentry/android/core/AndroidLogger : io/sentry/ILogger {
6776
public fun <init> ()V
6877
public fun <init> (Ljava/lang/String;)V
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package io.sentry.android.core;
2+
3+
import android.util.Log;
4+
import io.sentry.ILogger;
5+
import io.sentry.SentryLevel;
6+
import org.jetbrains.annotations.ApiStatus;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
9+
10+
@ApiStatus.Internal
11+
public final class AndroidFatalLogger implements ILogger {
12+
13+
private final @NotNull String tag;
14+
15+
public AndroidFatalLogger() {
16+
this("Sentry");
17+
}
18+
19+
public AndroidFatalLogger(final @NotNull String tag) {
20+
this.tag = tag;
21+
}
22+
23+
@SuppressWarnings("AnnotateFormatMethod")
24+
@Override
25+
public void log(
26+
final @NotNull SentryLevel level,
27+
final @NotNull String message,
28+
final @Nullable Object... args) {
29+
if (args == null || args.length == 0) {
30+
Log.println(toLogcatLevel(level), tag, message);
31+
} else {
32+
Log.println(toLogcatLevel(level), tag, String.format(message, args));
33+
}
34+
}
35+
36+
@SuppressWarnings("AnnotateFormatMethod")
37+
@Override
38+
public void log(
39+
final @NotNull SentryLevel level,
40+
final @Nullable Throwable throwable,
41+
final @NotNull String message,
42+
final @Nullable Object... args) {
43+
if (args == null || args.length == 0) {
44+
log(level, message, throwable);
45+
} else {
46+
log(level, String.format(message, args), throwable);
47+
}
48+
}
49+
50+
@Override
51+
public void log(
52+
final @NotNull SentryLevel level,
53+
final @NotNull String message,
54+
final @Nullable Throwable throwable) {
55+
Log.wtf(tag, message, throwable);
56+
}
57+
58+
@Override
59+
public boolean isEnabled(@Nullable SentryLevel level) {
60+
return true;
61+
}
62+
63+
private int toLogcatLevel(final @NotNull SentryLevel sentryLevel) {
64+
return Log.ASSERT;
65+
}
66+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.content.pm.PackageInfo;
88
import io.sentry.DeduplicateMultithreadedEventProcessor;
99
import io.sentry.DefaultCompositePerformanceCollector;
10+
import io.sentry.DefaultVersionDetector;
1011
import io.sentry.IContinuousProfiler;
1112
import io.sentry.ILogger;
1213
import io.sentry.ISentryLifecycleToken;
@@ -15,6 +16,7 @@
1516
import io.sentry.NoOpConnectionStatusProvider;
1617
import io.sentry.NoOpContinuousProfiler;
1718
import io.sentry.NoOpTransactionProfiler;
19+
import io.sentry.NoopVersionDetector;
1820
import io.sentry.ScopeType;
1921
import io.sentry.SendFireAndForgetEnvelopeSender;
2022
import io.sentry.SendFireAndForgetOutboxSender;
@@ -108,6 +110,7 @@ static void loadDefaultAndMetadataOptions(
108110

109111
// Firstly set the logger, if `debug=true` configured, logging can start asap.
110112
options.setLogger(logger);
113+
options.setFatalLogger(new AndroidFatalLogger());
111114

112115
options.setDefaultScopeType(ScopeType.CURRENT);
113116
options.setOpenTelemetryMode(SentryOpenTelemetryMode.OFF);
@@ -198,6 +201,9 @@ static void initializeIntegrationsAndProcessors(
198201
if (options.getDebugMetaLoader() instanceof NoOpDebugMetaLoader) {
199202
options.setDebugMetaLoader(new AssetsDebugMetaLoader(context, options.getLogger()));
200203
}
204+
if (options.getVersionDetector() instanceof NoopVersionDetector) {
205+
options.setVersionDetector(new DefaultVersionDetector(options));
206+
}
201207

202208
final boolean isAndroidXScrollViewAvailable =
203209
loadClass.isClassAvailable("androidx.core.view.ScrollingView", options);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ class InternalSentrySdkTest {
523523
val propagationContext = scope.propagationContext
524524
assertEquals(SentryId(traceId), propagationContext.traceId)
525525
assertEquals(SpanId(spanId), propagationContext.parentSpanId)
526-
assertEquals(sampleRate, propagationContext.baggage.sampleRateDouble)
527-
assertEquals(sampleRand, propagationContext.baggage.sampleRandDouble)
526+
assertEquals(sampleRate, propagationContext.baggage.sampleRate!!, 0.0001)
527+
assertEquals(sampleRand, propagationContext.baggage.sampleRand!!, 0.0001)
528528
}
529529
}
530530
}

sentry-android-fragment/src/main/java/io/sentry/android/fragment/FragmentLifecycleIntegration.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public class FragmentLifecycleIntegration(
2222
Integration,
2323
Closeable {
2424

25+
private companion object {
26+
init {
27+
SentryIntegrationPackageStorage.getInstance()
28+
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
29+
}
30+
}
31+
2532
public constructor(application: Application) : this(
2633
application = application,
2734
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states,
@@ -50,8 +57,6 @@ public class FragmentLifecycleIntegration(
5057
application.registerActivityLifecycleCallbacks(this)
5158
options.logger.log(DEBUG, "FragmentLifecycleIntegration installed.")
5259
addIntegrationToSdkVersion("FragmentLifecycle")
53-
SentryIntegrationPackageStorage.getInstance()
54-
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
5560
}
5661

5762
override fun close() {

sentry-android-navigation/src/main/java/io/sentry/android/navigation/SentryNavigationListener.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public class SentryNavigationListener @JvmOverloads constructor(
5050

5151
init {
5252
addIntegrationToSdkVersion("NavigationListener")
53-
SentryIntegrationPackageStorage.getInstance()
54-
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
5553
}
5654

5755
override fun onDestinationChanged(
@@ -195,5 +193,10 @@ public class SentryNavigationListener @JvmOverloads constructor(
195193

196194
public companion object {
197195
public const val NAVIGATION_OP: String = "navigation"
196+
197+
init {
198+
SentryIntegrationPackageStorage.getInstance()
199+
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
200+
}
198201
}
199202
}

sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdkUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.android.ndk;
22

3+
import io.sentry.SentryIntegrationPackageStorage;
34
import io.sentry.protocol.SdkVersion;
45
import org.jetbrains.annotations.Nullable;
56

@@ -8,6 +9,11 @@
89
*/
910
final class SentryNdkUtil {
1011

12+
static {
13+
SentryIntegrationPackageStorage.getInstance()
14+
.addPackage("maven:io.sentry:sentry-android-ndk", BuildConfig.VERSION_NAME);
15+
}
16+
1117
private SentryNdkUtil() {}
1218

1319
/**

sentry-android-replay/src/main/java/io/sentry/android/replay/ReplayIntegration.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public class ReplayIntegration(
7171
IConnectionStatusObserver,
7272
IRateLimitObserver {
7373

74+
private companion object {
75+
init {
76+
SentryIntegrationPackageStorage.getInstance()
77+
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)
78+
}
79+
}
80+
7481
// needed for the Java's call site
7582
public constructor(context: Context, dateProvider: ICurrentDateProvider) : this(
7683
context.appContext(),
@@ -151,8 +158,6 @@ public class ReplayIntegration(
151158
}
152159

153160
addIntegrationToSdkVersion("Replay")
154-
SentryIntegrationPackageStorage.getInstance()
155-
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)
156161

157162
finalizePreviousReplay()
158163
}

0 commit comments

Comments
 (0)