Skip to content

Commit 0d0e1d3

Browse files
github-actions[bot]web-flowmarkushi
authored
chore(deps): update Native SDK to v0.8.3 (#4298)
* chore: update scripts/update-sentry-native-ndk.sh to 0.8.3 * chore: update scripts/update-sentry-native-ndk.sh to 0.8.3 * Add glue code and additional tests --------- Co-authored-by: GitHub <[email protected]> Co-authored-by: Markus Hintersteiner <[email protected]>
1 parent 708d339 commit 0d0e1d3

File tree

4 files changed

+84
-4
lines changed

4 files changed

+84
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838

3939
### Dependencies
4040

41-
- Bump Native SDK from v0.8.1 to v0.8.2 ([#4267](https://github.com/getsentry/sentry-java/pull/4267))
42-
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#082)
43-
- [diff](https://github.com/getsentry/sentry-native/compare/0.8.1...0.8.2)
41+
- Bump Native SDK from v0.8.1 to v0.8.3 ([#4267](https://github.com/getsentry/sentry-java/pull/4267), [#4298](https://github.com/getsentry/sentry-java/pull/4298))
42+
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#083)
43+
- [diff](https://github.com/getsentry/sentry-native/compare/0.8.1...0.8.3)
4444
- Bump Spring Boot from 2.7.5 to 2.7.18 ([#3496](https://github.com/getsentry/sentry-java/pull/3496))
4545

4646
## 8.5.0

buildSrc/src/main/java/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ object Config {
161161
val apolloKotlin = "com.apollographql.apollo3:apollo-runtime:3.8.2"
162162
val apolloKotlin4 = "com.apollographql.apollo:apollo-runtime:4.1.1"
163163

164-
val sentryNativeNdk = "io.sentry:sentry-native-ndk:0.8.2"
164+
val sentryNativeNdk = "io.sentry:sentry-native-ndk:0.8.3"
165165

166166
object OpenTelemetry {
167167
val otelVersion = "1.44.1"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.concurrent.TimeUnit;
1010
import org.jetbrains.annotations.ApiStatus;
1111
import org.jetbrains.annotations.NotNull;
12+
import org.jetbrains.annotations.Nullable;
1213

1314
@ApiStatus.Internal
1415
public final class SentryNdk {
@@ -65,6 +66,13 @@ public static void init(@NotNull final SentryAndroidOptions options) {
6566
io.sentry.ndk.NdkHandlerStrategy.SENTRY_HANDLER_STRATEGY_CHAIN_AT_START);
6667
}
6768

69+
final @Nullable Double tracesSampleRate = options.getTracesSampleRate();
70+
if (tracesSampleRate == null) {
71+
ndkOptions.setTracesSampleRate(0.0f);
72+
} else {
73+
ndkOptions.setTracesSampleRate(tracesSampleRate.floatValue());
74+
}
75+
6876
//noinspection UnstableApiUsage
6977
io.sentry.ndk.SentryNdk.init(ndkOptions);
7078

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package io.sentry.android.ndk
2+
3+
import io.sentry.android.core.SentryAndroidOptions
4+
import io.sentry.ndk.NdkOptions
5+
import org.junit.Test
6+
import org.mockito.Mockito
7+
import org.mockito.kotlin.any
8+
import org.mockito.kotlin.doAnswer
9+
import kotlin.test.assertEquals
10+
import kotlin.test.assertNotNull
11+
12+
@Suppress("UnstableApiUsage")
13+
class SentryNdkTest {
14+
15+
class Fixture {
16+
17+
var capturedOptions: NdkOptions? = null
18+
19+
fun getSut(
20+
options: SentryAndroidOptions = SentryAndroidOptions().apply {
21+
dsn = "https://[email protected]/proj"
22+
cacheDirPath = "/cache"
23+
},
24+
closure: () -> Unit
25+
) {
26+
Mockito.mockStatic(io.sentry.ndk.SentryNdk::class.java).use { utils ->
27+
utils.`when`<Any> { io.sentry.ndk.SentryNdk.init(any<NdkOptions>()) }.doAnswer {
28+
capturedOptions = it.arguments[0] as NdkOptions
29+
}
30+
SentryNdk.init(options)
31+
closure.invoke()
32+
}
33+
}
34+
}
35+
36+
val fixture = Fixture()
37+
38+
@Test
39+
fun `SentryNdk calls NDK init`() {
40+
fixture.getSut() {
41+
assertNotNull(fixture.capturedOptions)
42+
}
43+
}
44+
45+
@Test
46+
fun `SentryNdk propagates null tracesSampleRate`() {
47+
fixture.getSut(
48+
options = SentryAndroidOptions().apply {
49+
dsn = "https://[email protected]/proj"
50+
cacheDirPath = "/cache"
51+
tracesSampleRate = null
52+
}
53+
) {
54+
assertNotNull(fixture.capturedOptions)
55+
assertEquals(0.0f, fixture.capturedOptions!!.tracesSampleRate, 0.0001f)
56+
}
57+
}
58+
59+
@Test
60+
fun `SentryNdk propagates non-null tracesSampleRate`() {
61+
fixture.getSut(
62+
options = SentryAndroidOptions().apply {
63+
dsn = "https://[email protected]/proj"
64+
cacheDirPath = "/cache"
65+
tracesSampleRate = 0.75
66+
}
67+
) {
68+
assertNotNull(fixture.capturedOptions)
69+
assertEquals(0.75f, fixture.capturedOptions!!.tracesSampleRate, 0.0001f)
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)