Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

## Unreleased

### Behavioral Changes

- The Sentry SDK will now crash on startup if mixed versions have been detected ([#4277](https://github.com/getsentry/sentry-java/pull/4277))
- On `Sentry.init` / `SentryAndroid.init` the SDK now checks if all Sentry Java / Android SDK dependencies have the same version.
- 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.
- 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.
- 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))
- This takes care of cases missed by the startup check above due to older versions.

### Features

- 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))
- Add `MANIFEST.MF` to Sentry JARs ([#4272](https://github.com/getsentry/sentry-java/pull/4272))

### Fixes

Expand Down
10 changes: 10 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,21 @@ object Config {
val SENTRY_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring"
val SENTRY_SPRING_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring.jakarta"
val SENTRY_SPRING_BOOT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot"
val SENTRY_SPRING_BOOT_STARTER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter"
val SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot.jakarta"
val SENTRY_SPRING_BOOT_STARTER_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot-starter.jakarta"
val SENTRY_OPENTELEMETRY_BOOTSTRAP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.bootstrap"
val SENTRY_OPENTELEMETRY_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.core"
val SENTRY_OPENTELEMETRY_AGENT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agent"
val SENTRY_OPENTELEMETRY_AGENTLESS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless"
val SENTRY_OPENTELEMETRY_AGENTLESS_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless-spring"
val SENTRY_OPENTELEMETRY_AGENTCUSTOMIZATION_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentcustomization"
val SENTRY_OPENFEIGN_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.openfeign"
val SENTRY_APOLLO3_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo3"
val SENTRY_APOLLO4_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo4"
val SENTRY_APOLLO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo"
val SENTRY_GRAPHQL_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql"
val SENTRY_GRAPHQL_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql-core"
val SENTRY_GRAPHQL22_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql22"
val SENTRY_QUARTZ_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.quartz"
val SENTRY_JDBC_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.jdbc"
Expand All @@ -265,6 +274,7 @@ object Config {
val SENTRY_COMPOSE_HELPER_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.compose.helper"
val SENTRY_OKHTTP_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.okhttp"
val SENTRY_REACTOR_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.reactor"
val SENTRY_KOTLIN_EXTENSIONS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.kotlin-extensions"
val group = "io.sentry"
val description = "SDK for sentry.io"
val versionNameProp = "versionName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.pm.PackageInfo;
import io.sentry.DeduplicateMultithreadedEventProcessor;
import io.sentry.DefaultCompositePerformanceCollector;
import io.sentry.DefaultVersionDetector;
import io.sentry.IContinuousProfiler;
import io.sentry.ILogger;
import io.sentry.ISentryLifecycleToken;
Expand All @@ -15,6 +16,7 @@
import io.sentry.NoOpConnectionStatusProvider;
import io.sentry.NoOpContinuousProfiler;
import io.sentry.NoOpTransactionProfiler;
import io.sentry.NoopVersionDetector;
import io.sentry.ScopeType;
import io.sentry.SendFireAndForgetEnvelopeSender;
import io.sentry.SendFireAndForgetOutboxSender;
Expand Down Expand Up @@ -198,6 +200,9 @@ static void initializeIntegrationsAndProcessors(
if (options.getDebugMetaLoader() instanceof NoOpDebugMetaLoader) {
options.setDebugMetaLoader(new AssetsDebugMetaLoader(context, options.getLogger()));
}
if (options.getVersionDetector() instanceof NoopVersionDetector) {
options.setVersionDetector(new DefaultVersionDetector(options));
}

final boolean isAndroidXScrollViewAvailable =
loadClass.isClassAvailable("androidx.core.view.ScrollingView", options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class FragmentLifecycleIntegration(
Integration,
Closeable {

private companion object {
init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
}
}

public constructor(application: Application) : this(
application = application,
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,10 @@ public class SentryNavigationListener @JvmOverloads constructor(

public companion object {
public const val NAVIGATION_OP: String = "navigation"

init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.android.ndk;

import io.sentry.SentryIntegrationPackageStorage;
import io.sentry.protocol.SdkVersion;
import org.jetbrains.annotations.Nullable;

Expand All @@ -8,6 +9,11 @@
*/
final class SentryNdkUtil {

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-ndk", BuildConfig.VERSION_NAME);
}

private SentryNdkUtil() {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public class ReplayIntegration(
IConnectionStatusObserver,
IRateLimitObserver {

private companion object {
init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)
}
}

// needed for the Java's call site
public constructor(context: Context, dateProvider: ICurrentDateProvider) : this(
context.appContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public class SentryTimberIntegration(
private lateinit var tree: SentryTimberTree
private lateinit var logger: ILogger

private companion object {
init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-timber", VERSION_NAME)
}
}

override fun register(scopes: IScopes, options: SentryOptions) {
logger = options.logger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,5 +453,10 @@ class SentryApollo3HttpInterceptor @JvmOverloads constructor(
const val SENTRY_APOLLO_3_VARIABLES = "SENTRY-APOLLO-3-VARIABLES"
const val SENTRY_APOLLO_3_OPERATION_TYPE = "SENTRY-APOLLO-3-OPERATION-TYPE"
const val DEFAULT_CAPTURE_FAILED_REQUESTS = true

init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-apollo-3", BuildConfig.VERSION_NAME)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,5 +449,10 @@ class SentryApollo4HttpInterceptor @JvmOverloads constructor(

companion object {
const val DEFAULT_CAPTURE_FAILED_REQUESTS = true

init {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-apollo-4", BuildConfig.VERSION_NAME)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class SentryApolloInterceptor(
private val beforeSpan: BeforeSpanCallback? = null
) : ApolloInterceptor {

private companion object {
init {
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-apollo", BuildConfig.VERSION_NAME)
}
}

constructor(scopes: IScopes) : this(scopes, null)
constructor(beforeSpan: BeforeSpanCallback) : this(ScopesAdapter.getInstance(), beforeSpan)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public final class ComposeGestureTargetLocator implements GestureTargetLocator {
private volatile @Nullable SentryComposeHelper composeHelper;
private final @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-compose", BuildConfig.VERSION_NAME);
}

public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
this.logger = logger;
SentryIntegrationPackageStorage.getInstance().addIntegration("ComposeUserInteraction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ internal class SentryLifecycleObserver(
SentryNavigationListener(traceOriginAppendix = TRACE_ORIGIN_APPENDIX)
) : LifecycleEventObserver {

private companion object {
init {
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-compose", BuildConfig.VERSION_NAME)
}
}

init {
addIntegrationToSdkVersion("ComposeNavigation")
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-compose", BuildConfig.VERSION_NAME)
Expand Down
13 changes: 13 additions & 0 deletions sentry-graphql-22/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ buildConfig {
buildConfigField("String", "SENTRY_GRAPHQL22_SDK_NAME", "\"${Config.Sentry.SENTRY_GRAPHQL22_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_GRAPHQL22_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-graphql-22",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
public final class SentryInstrumentation
extends graphql.execution.instrumentation.SimplePerformantInstrumentation {

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-graphql-22", BuildConfig.VERSION_NAME);
}

/**
* @deprecated please use {@link SentryGraphqlInstrumentation#SENTRY_SCOPES_CONTEXT_KEY}
*/
Expand Down
13 changes: 13 additions & 0 deletions sentry-graphql-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ buildConfig {
buildConfigField("String", "SENTRY_GRAPHQL_SDK_NAME", "\"${Config.Sentry.SENTRY_GRAPHQL_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_GRAPHQL_CORE_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-graphql-core",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
13 changes: 13 additions & 0 deletions sentry-graphql/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ buildConfig {
buildConfigField("String", "SENTRY_GRAPHQL_SDK_NAME", "\"${Config.Sentry.SENTRY_GRAPHQL_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_GRAPHQL_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-graphql",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
public final class SentryInstrumentation
extends graphql.execution.instrumentation.SimpleInstrumentation {

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-graphql", BuildConfig.VERSION_NAME);
}

/**
* @deprecated please use {@link SentryGraphqlInstrumentation#SENTRY_SCOPES_CONTEXT_KEY}
*/
Expand Down
13 changes: 13 additions & 0 deletions sentry-jdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,16 @@ buildConfig {
buildConfigField("String", "SENTRY_JDBC_SDK_NAME", "\"${Config.Sentry.SENTRY_JDBC_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_JDBC_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-jdbc",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class SentryJdbcEventListener extends SimpleJdbcEventListener {
protected final @NotNull AutoClosableReentrantLock databaseDetailsLock =
new AutoClosableReentrantLock();

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-jdbc", BuildConfig.VERSION_NAME);
}

public SentryJdbcEventListener(final @NotNull IScopes scopes) {
this.scopes = Objects.requireNonNull(scopes, "scopes are required");
addPackageAndIntegrationInfo();
Expand Down
13 changes: 13 additions & 0 deletions sentry-jul/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ tasks.withType<JavaCompile>().configureEach {
option("NullAway:AnnotatedPackages", "io.sentry")
}
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_JUL_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-jul",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
5 changes: 5 additions & 0 deletions sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public class SentryHandler extends Handler {
private @NotNull Level minimumBreadcrumbLevel = Level.INFO;
private @NotNull Level minimumEventLevel = Level.SEVERE;

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-jul", BuildConfig.VERSION_NAME);
}

/** Creates an instance of SentryHandler. */
public SentryHandler() {
this(new SentryOptions());
Expand Down
13 changes: 13 additions & 0 deletions sentry-kotlin-extensions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@ tasks.withType<Detekt> {
kotlin {
explicitApi()
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_KOTLIN_EXTENSIONS_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-kotlin-extensions",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
13 changes: 13 additions & 0 deletions sentry-log4j2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,16 @@ tasks.withType<JavaCompile>().configureEach {
option("NullAway:AnnotatedPackages", "io.sentry")
}
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_LOG4J2_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-log4j2",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public class SentryAppender extends AbstractAppender {
private final @NotNull IScopes scopes;
private final @Nullable List<String> contextTags;

static {
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-log4j2", BuildConfig.VERSION_NAME);
}

public SentryAppender(
final @NotNull String name,
final @Nullable Filter filter,
Expand Down
Loading
Loading