Skip to content

Commit

Permalink
Merge branch 'main' into feat/update-otel-sample-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lbloder authored Jan 21, 2025
2 parents c7e9000 + 1eb21a0 commit cbececc
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 336 deletions.
9 changes: 5 additions & 4 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ targets:
maven:io.sentry:sentry-openfeign:
maven:io.sentry:sentry-opentelemetry-agent:
maven:io.sentry:sentry-opentelemetry-agentcustomization:
maven:io.sentry:sentry-opentelemetry-agentless:
maven:io.sentry:sentry-opentelemetry-agentless-spring:
maven:io.sentry:sentry-opentelemetry-bootstrap:
maven:io.sentry:sentry-opentelemetry-core:
# maven:io.sentry:sentry-opentelemetry-agentless:
# maven:io.sentry:sentry-opentelemetry-agentless-spring:
maven:io.sentry:sentry-apollo:
maven:io.sentry:sentry-jdbc:
maven:io.sentry:sentry-graphql:
# maven:io.sentry:sentry-graphql-core:
# maven:io.sentry:sentry-graphql-22:
maven:io.sentry:sentry-graphql-22:
maven:io.sentry:sentry-graphql-core:
maven:io.sentry:sentry-quartz:
maven:io.sentry:sentry-okhttp:
maven:io.sentry:sentry-android-navigation:
Expand Down
509 changes: 198 additions & 311 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=true

# Release information
versionName=8.0.0-rc.4
versionName=8.0.0

# Override the SDK name on native crashes on Android
sentryAndroidSdkName=sentry.native.android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
if (user.getId() == null) {
user.setId(getDeviceId());
}
if (user.getIpAddress() == null) {
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
if (user.getId() == null) {
user.setId(Installation.id(context));
}
if (user.getIpAddress() == null) {
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@ class AnrV2EventProcessorTest {
lateinit var context: Context
val options = SentryAndroidOptions().apply {
setLogger(NoOpLogger.getInstance())
isSendDefaultPii = true
}

fun getSut(
dir: TemporaryFolder,
currentSdk: Int = Build.VERSION_CODES.LOLLIPOP,
populateScopeCache: Boolean = false,
populateOptionsCache: Boolean = false,
replayErrorSampleRate: Double? = null
replayErrorSampleRate: Double? = null,
isSendDefaultPii: Boolean = true
): AnrV2EventProcessor {
options.cacheDirPath = dir.newFolder().absolutePath
options.environment = "release"
options.isSendDefaultPii = isSendDefaultPii

whenever(buildInfo.sdkInfoVersion).thenReturn(currentSdk)
whenever(buildInfo.isEmulator).thenReturn(true)

Expand Down Expand Up @@ -278,6 +280,7 @@ class AnrV2EventProcessorTest {
// user
assertEquals("bot", processed.user!!.username)
assertEquals("[email protected]", processed.user!!.id)
assertEquals("{{auto}}", processed.user!!.ipAddress)
// trace
assertEquals("ui.load", processed.contexts.trace!!.operation)
// tags
Expand All @@ -304,6 +307,13 @@ class AnrV2EventProcessorTest {
assertEquals("Google Chrome", processed.contexts.browser!!.name)
}

@Test
fun `when backfillable event is enrichable, does not backfill user ip`() {
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
assertNull(processed.user!!.ipAddress)
}

@Test
fun `when backfillable event is enrichable, backfills serialized options data`() {
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
Expand Down Expand Up @@ -617,14 +627,16 @@ class AnrV2EventProcessorTest {
hint: Hint,
populateScopeCache: Boolean = false,
populateOptionsCache: Boolean = false,
isSendDefaultPii: Boolean = true,
configureEvent: SentryEvent.() -> Unit = {}
): SentryEvent {
val original = SentryEvent().apply(configureEvent)

val processor = fixture.getSut(
tmpDir,
populateScopeCache = populateScopeCache,
populateOptionsCache = populateOptionsCache
populateOptionsCache = populateOptionsCache,
isSendDefaultPii = isSendDefaultPii
)
return processor.process(original, hint)!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class DefaultAndroidEventProcessorTest {

lateinit var sentryTracer: SentryTracer

fun getSut(context: Context): DefaultAndroidEventProcessor {
fun getSut(
context: Context,
isSendDefaultPii: Boolean = false
): DefaultAndroidEventProcessor {
options.isSendDefaultPii = isSendDefaultPii
whenever(scopes.options).thenReturn(options)
sentryTracer = SentryTracer(TransactionContext("", ""), scopes)
return DefaultAndroidEventProcessor(context, buildInfo, options)
Expand Down Expand Up @@ -284,8 +288,20 @@ class DefaultAndroidEventProcessorTest {
}

@Test
fun `when event user data does not have ip address set, sets {{auto}} as the ip address`() {
val sut = fixture.getSut(context)
fun `when event user data does not have ip address set, sets no ip address if sendDefaultPii is false`() {
val sut = fixture.getSut(context, isSendDefaultPii = false)
val event = SentryEvent().apply {
user = User()
}
sut.process(event, Hint())
assertNotNull(event.user) {
assertNull(it.ipAddress)
}
}

@Test
fun `when event user data does not have ip address set, sets {{auto}} if sendDefaultPii is true`() {
val sut = fixture.getSut(context, isSendDefaultPii = true)
val event = SentryEvent().apply {
user = User()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ private SentryNdk() {}
try {
//noinspection UnstableApiUsage
io.sentry.ndk.SentryNdk.loadNativeLibraries();
} catch (Throwable t) {
// ignored
// if loadLibrary() fails, the later init() will throw an exception anyway
} finally {
loadLibraryLatch.countDown();
}
Expand Down
1 change: 1 addition & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,7 @@ public final class io/sentry/SentryBaseEvent$Serializer {
}

public final class io/sentry/SentryClient : io/sentry/ISentryClient {
public fun <init> (Lio/sentry/SentryOptions;)V
public fun captureCheckIn (Lio/sentry/CheckIn;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
public fun captureEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/MainEventProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
user = new User();
event.setUser(user);
}
if (user.getIpAddress() == null) {
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
}
}
Expand Down
3 changes: 2 additions & 1 deletion sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public boolean isEnabled() {
return enabled;
}

SentryClient(final @NotNull SentryOptions options) {
@ApiStatus.Internal
public SentryClient(final @NotNull SentryOptions options) {
this.options = Objects.requireNonNull(options, "SentryOptions is required.");
this.enabled = true;

Expand Down
4 changes: 3 additions & 1 deletion sentry/src/main/java/io/sentry/SentryExceptionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ Deque<SentryException> extractExceptionQueueInternal(

Throwable[] suppressed = currentThrowable.getSuppressed();
if (suppressed != null && suppressed.length > 0) {
exceptionMechanism.setExceptionGroup(true);
// Disabled for now as it causes grouping in Sentry to sometimes use
// the suppressed exception as main exception.
// exceptionMechanism.setExceptionGroup(true);
for (Throwable suppressedThrowable : suppressed) {
extractExceptionQueueInternal(
suppressedThrowable, exceptionId, circularityDetector, exceptions);
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/test/java/io/sentry/MainEventProcessorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ class MainEventProcessorTest {
}
}

@Test
fun `when event does not have ip address set, do not enrich ip address if sendDefaultPii is false`() {
val sut = fixture.getSut(sendDefaultPii = false)
val event = SentryEvent()
sut.process(event, Hint())
assertNotNull(event.user) {
assertNull(it.ipAddress)
}
}

@Test
fun `when event has ip address set, keeps original ip address`() {
val sut = fixture.getSut(sendDefaultPii = true)
Expand Down
18 changes: 9 additions & 9 deletions sentry/src/test/java/io/sentry/SentryExceptionFactoryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class SentryExceptionFactoryTest {

assertEquals("message", mainInQueue.value)
assertEquals(0, mainInQueue.mechanism?.exceptionId)
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
}

@Test
Expand All @@ -255,12 +255,12 @@ class SentryExceptionFactoryTest {
assertEquals("inner", mainInQueue.value)
assertEquals(1, mainInQueue.mechanism?.exceptionId)
assertEquals(0, mainInQueue.mechanism?.parentId)
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)

assertEquals("outer", outerInQueue.value)
assertEquals(0, outerInQueue.mechanism?.exceptionId)
assertNull(outerInQueue.mechanism?.parentId)
assertNull(outerInQueue.mechanism?.isExceptionGroup)
// assertNull(outerInQueue.mechanism?.isExceptionGroup)
}

@Test
Expand Down Expand Up @@ -288,12 +288,12 @@ class SentryExceptionFactoryTest {
assertEquals("inner", mainInQueue.value)
assertEquals(1, mainInQueue.mechanism?.exceptionId)
assertEquals(0, mainInQueue.mechanism?.parentId)
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)

assertEquals("outer", outerInQueue.value)
assertEquals(0, outerInQueue.mechanism?.exceptionId)
assertNull(outerInQueue.mechanism?.parentId)
assertNull(outerInQueue.mechanism?.isExceptionGroup)
// assertNull(outerInQueue.mechanism?.isExceptionGroup)
}

@Test
Expand Down Expand Up @@ -324,7 +324,7 @@ class SentryExceptionFactoryTest {
assertEquals("innermost", innerMostExceptionInQueue.value)
assertEquals(3, innerMostExceptionInQueue.mechanism?.exceptionId)
assertEquals(1, innerMostExceptionInQueue.mechanism?.parentId)
assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)

assertEquals("suppressed", innerSuppressedInQueue.value)
assertEquals(2, innerSuppressedInQueue.mechanism?.exceptionId)
Expand All @@ -334,7 +334,7 @@ class SentryExceptionFactoryTest {
assertEquals("inner", innerExceptionInQueue.value)
assertEquals(1, innerExceptionInQueue.mechanism?.exceptionId)
assertEquals(0, innerExceptionInQueue.mechanism?.parentId)
assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)

assertEquals("outer", outerInQueue.value)
assertEquals(0, outerInQueue.mechanism?.exceptionId)
Expand Down Expand Up @@ -378,7 +378,7 @@ class SentryExceptionFactoryTest {
assertEquals("innermost", innerMostExceptionInQueue.value)
assertEquals(3, innerMostExceptionInQueue.mechanism?.exceptionId)
assertEquals(1, innerMostExceptionInQueue.mechanism?.parentId)
assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)

assertEquals("suppressed", innerSuppressedInQueue.value)
assertEquals(2, innerSuppressedInQueue.mechanism?.exceptionId)
Expand All @@ -388,7 +388,7 @@ class SentryExceptionFactoryTest {
assertEquals("inner", innerExceptionInQueue.value)
assertEquals(1, innerExceptionInQueue.mechanism?.exceptionId)
assertEquals(0, innerExceptionInQueue.mechanism?.parentId)
assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
// assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)

assertEquals("outer", outerInQueue.value)
assertEquals(0, outerInQueue.mechanism?.exceptionId)
Expand Down

0 comments on commit cbececc

Please sign in to comment.