Skip to content

Commit 13cb0b5

Browse files
authored
Merge branch 'main' into fix/fewer-npes
2 parents 4d59c40 + 251127d commit 13cb0b5

File tree

146 files changed

+1778
-3272
lines changed

Some content is hidden

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

146 files changed

+1778
-3272
lines changed

.github/workflows/system-tests-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
102102
- name: Start server and run integration test for sentry-cli commands
103103
run: |
104-
test/system-test-run.sh "${{ matrix.sample }}" "${{ matrix.agent }}" "${{ matrix.agent-auto-init }}"
104+
test/system-test-run.sh "${{ matrix.sample }}" "${{ matrix.agent }}" "${{ matrix.agent-auto-init }}" "0"
105105
106106
- name: Upload test results
107107
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ distributions/
2020
sentry-spring-boot-starter-jakarta/src/main/resources/META-INF/spring.factories
2121
sentry-samples/sentry-samples-spring-boot-jakarta/spy.log
2222
spy.log
23+
buildSrc/.kotlin/

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## Unreleased
4+
35
### Fixes
46

57
- The SDK now handles `null` on many APIs instead of expecting a non `null` value ([#4245](https://github.com/getsentry/sentry-java/pull/4245))
@@ -8,16 +10,30 @@
810
- If `null` is passed, the SDK will
911
- do nothing if a `null` key is passed, returning `null` for non void methods
1012
- replace any previous value if the new value is set to `null`
13+
- Add support for setting in-app-includes/in-app-excludes via AndroidManifest.xml ([#4240](https://github.com/getsentry/sentry-java/pull/4240))
14+
- Modifications to OkHttp requests are now properly propagated to the affected span / breadcrumbs ([#4238](https://github.com/getsentry/sentry-java/pull/4238))
15+
- Please ensure the SentryOkHttpInterceptor is added last to your OkHttpClient, as otherwise changes to the `Request` by subsequent interceptors won't be considered
1116

1217
### Features
1318

1419
- The SDK now automatically propagates the trace-context to the native layer. This allows to connect errors on different layers of the application. ([#4137](https://github.com/getsentry/sentry-java/pull/4137))
20+
- Capture OpenTelemetry span events ([#3564](https://github.com/getsentry/sentry-java/pull/3564))
21+
- OpenTelemetry spans may have exceptions attached to them (`openTelemetrySpan.recordException`). We can now send those to Sentry as errors.
22+
- Set `capture-open-telemetry-events=true` in `sentry.properties` to enable it
23+
- Set `sentry.capture-open-telemetry-events=true` in Springs `application.properties` to enable it
24+
- Set `sentry.captureOpenTelemetryEvents: true` in Springs `application.yml` to enable it
1525

1626
### Behavioural Changes
1727

1828
- Use `java.net.URI` for parsing URLs in `UrlUtils` ([#4210](https://github.com/getsentry/sentry-java/pull/4210))
1929
- This could affect grouping for issues with messages containing URLs that fall in known corner cases that were handled incorrectly previously (e.g. email in URL path)
2030

31+
### Internal
32+
33+
- Also use port when checking if a request is made to Sentry DSN ([#4231](https://github.com/getsentry/sentry-java/pull/4231))
34+
- For our OpenTelemetry integration we check if a span is for a request to Sentry
35+
- We now also consider the port when performing this check
36+
2137
### Dependencies
2238

2339
- Bump Native SDK from v0.7.20 to v0.8.1 ([#4137](https://github.com/getsentry/sentry-java/pull/4137))

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ subprojects {
155155
}
156156
}
157157

158-
if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-test-support" && this.name != "sentry-compose-helper") {
158+
if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-system-test-support" && this.name != "sentry-test-support" && this.name != "sentry-compose-helper") {
159159
apply<DistributionPlugin>()
160160
apply<com.vanniktech.maven.publish.MavenPublishPlugin>()
161161

buildSrc/src/main/java/Config.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ object Config {
7575
val log4j2Core = "org.apache.logging.log4j:log4j-core:$log4j2Version"
7676

7777
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind"
78+
val jacksonKotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:2.18.3"
7879

7980
val springBootStarter = "org.springframework.boot:spring-boot-starter:$springBootVersion"
8081
val springBootStarterGraphql = "org.springframework.boot:spring-boot-starter-graphql:$springBootVersion"

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ coverage:
1616
ignore:
1717
- "**/src/test/*"
1818
- "sentry-android-integration-tests/*"
19+
- "sentry-system-test-support/*"
1920
- "sentry-test-support/*"
2021
- "sentry-samples/*"

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ final class ManifestMetadataReader {
107107

108108
static final String IGNORED_ERRORS = "io.sentry.ignored-errors";
109109

110+
static final String IN_APP_INCLUDES = "io.sentry.in-app-includes";
111+
112+
static final String IN_APP_EXCLUDES = "io.sentry.in-app-excludes";
113+
110114
static final String ENABLE_AUTO_TRACE_ID_GENERATION =
111115
"io.sentry.traces.enable-auto-id-generation";
112116

@@ -414,8 +418,21 @@ static void applyMetadata(
414418
.setMaskAllImages(readBool(metadata, logger, REPLAYS_MASK_ALL_IMAGES, true));
415419

416420
options.setIgnoredErrors(readList(metadata, logger, IGNORED_ERRORS));
417-
}
418421

422+
final @Nullable List<String> includes = readList(metadata, logger, IN_APP_INCLUDES);
423+
if (includes != null && !includes.isEmpty()) {
424+
for (final @NotNull String include : includes) {
425+
options.addInAppInclude(include);
426+
}
427+
}
428+
429+
final @Nullable List<String> excludes = readList(metadata, logger, IN_APP_EXCLUDES);
430+
if (excludes != null && !excludes.isEmpty()) {
431+
for (final @NotNull String exclude : excludes) {
432+
options.addInAppExclude(exclude);
433+
}
434+
}
435+
}
419436
options
420437
.getLogger()
421438
.log(SentryLevel.INFO, "Retrieving configuration from AndroidManifest.xml");

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,4 +1447,54 @@ class ManifestMetadataReaderTest {
14471447
// Assert
14481448
assertEquals(listOf(FilterString("Some error"), FilterString("Another .*")), fixture.options.ignoredErrors)
14491449
}
1450+
1451+
@Test
1452+
fun `applyMetadata reads inAppIncludes to options and sets the value if found`() {
1453+
// Arrange
1454+
val bundle = bundleOf(ManifestMetadataReader.IN_APP_INCLUDES to "com.example.package1,com.example.package2")
1455+
val context = fixture.getContext(metaData = bundle)
1456+
1457+
// Act
1458+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1459+
1460+
// Assert
1461+
assertEquals(listOf("com.example.package1", "com.example.package2"), fixture.options.inAppIncludes)
1462+
}
1463+
1464+
@Test
1465+
fun `applyMetadata reads inAppIncludes to options and keeps empty if not found`() {
1466+
// Arrange
1467+
val context = fixture.getContext()
1468+
1469+
// Act
1470+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1471+
1472+
// Assert
1473+
assertTrue(fixture.options.inAppIncludes.isEmpty())
1474+
}
1475+
1476+
@Test
1477+
fun `applyMetadata reads inAppExcludes to options and sets the value if found`() {
1478+
// Arrange
1479+
val bundle = bundleOf(ManifestMetadataReader.IN_APP_EXCLUDES to "com.example.excluded1,com.example.excluded2")
1480+
val context = fixture.getContext(metaData = bundle)
1481+
1482+
// Act
1483+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1484+
1485+
// Assert
1486+
assertEquals(listOf("com.example.excluded1", "com.example.excluded2"), fixture.options.inAppExcludes)
1487+
}
1488+
1489+
@Test
1490+
fun `applyMetadata reads inAppExcludes to options and keeps empty if not found`() {
1491+
// Arrange
1492+
val context = fixture.getContext()
1493+
1494+
// Act
1495+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1496+
1497+
// Assert
1498+
assertTrue(fixture.options.inAppExcludes.isEmpty())
1499+
}
14501500
}

sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpEvent.kt

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,59 @@ internal class SentryOkHttpEvent(private val scopes: IScopes, private val reques
2828
private var response: Response? = null
2929
private var clientErrorResponse: Response? = null
3030
private val isEventFinished = AtomicBoolean(false)
31-
private val url: String
32-
private val method: String
31+
private var url: String
32+
private var method: String
3333

3434
init {
3535
val urlDetails = UrlUtils.parse(request.url.toString())
3636
url = urlDetails.urlOrFallback
37-
val host: String = request.url.host
38-
val encodedPath: String = request.url.encodedPath
3937
method = request.method
4038

4139
// We start the call span that will contain all the others
4240
val parentSpan = if (Platform.isAndroid()) scopes.transaction else scopes.span
43-
callSpan = parentSpan?.startChild("http.client", "$method $url")
41+
callSpan = parentSpan?.startChild("http.client")
4442
callSpan?.spanContext?.origin = TRACE_ORIGIN
43+
44+
breadcrumb = Breadcrumb().apply {
45+
type = "http"
46+
category = "http"
47+
// needs this as unix timestamp for rrweb
48+
setData(
49+
SpanDataConvention.HTTP_START_TIMESTAMP,
50+
CurrentDateProvider.getInstance().currentTimeMillis
51+
)
52+
}
53+
54+
setRequest(request)
55+
}
56+
57+
/**
58+
* Sets the request.
59+
* This function may be called multiple times in case the request changes e.g. due to interceptors.
60+
*/
61+
fun setRequest(request: Request) {
62+
val urlDetails = UrlUtils.parse(request.url.toString())
63+
url = urlDetails.urlOrFallback
64+
65+
val host: String = request.url.host
66+
val encodedPath: String = request.url.encodedPath
67+
method = request.method
68+
69+
callSpan?.description = "$method $url"
4570
urlDetails.applyToSpan(callSpan)
4671

47-
// We setup a breadcrumb with all meaningful data
48-
breadcrumb = Breadcrumb.http(url, method)
4972
breadcrumb.setData("host", host)
5073
breadcrumb.setData("path", encodedPath)
51-
// needs this as unix timestamp for rrweb
52-
breadcrumb.setData(SpanDataConvention.HTTP_START_TIMESTAMP, CurrentDateProvider.getInstance().currentTimeMillis)
74+
if (urlDetails.url != null) {
75+
breadcrumb.setData("url", urlDetails.url!!)
76+
}
77+
breadcrumb.setData("method", method.uppercase())
78+
if (urlDetails.query != null) {
79+
breadcrumb.setData("http.query", urlDetails.query!!)
80+
}
81+
if (urlDetails.fragment != null) {
82+
breadcrumb.setData("http.fragment", urlDetails.fragment!!)
83+
}
5384

5485
// We add the same data to the call span
5586
callSpan?.setData("url", url)

sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpInterceptor.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public open class SentryOkHttpInterceptor(
8181
val parentSpan = if (Platform.isAndroid()) scopes.transaction else scopes.span
8282
span = parentSpan?.startChild("http.client", "$method $url")
8383
}
84+
8485
val startTimestamp = CurrentDateProvider.getInstance().currentTimeMillis
8586

8687
span?.spanContext?.origin = TRACE_ORIGIN
@@ -141,6 +142,10 @@ public open class SentryOkHttpInterceptor(
141142
}
142143
throw e
143144
} finally {
145+
// interceptors may change the request details, so let's update it here
146+
// this only works correctly if SentryOkHttpInterceptor is the last one in the chain
147+
okHttpEvent?.setRequest(request)
148+
144149
finishSpan(span, request, response, isFromEventListener, okHttpEvent)
145150

146151
// The SentryOkHttpEventListener will send the breadcrumb itself if used for this call

0 commit comments

Comments
 (0)