Skip to content

Commit 908fa26

Browse files
committed
Merge branch 'main' into 9.x.x
2 parents 14d2d95 + 2028874 commit 908fa26

130 files changed

Lines changed: 7082 additions & 522 deletions

File tree

Some content is hidden

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

‎CHANGELOG.md‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,128 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- Add `LocalSentrySpan` to `sentry-compose` so apps can provide a parent `ISpan` to a composable subtree and have nested `SentryTraced` spans attach to it ([#6112]https://github.com/getsentry/sentry-java/pull/6112)
8+
- Add `dataCollection`, a fine-grained replacement for `sendDefaultPii`, for controlling data collected automatically by SDK integrations ([#5759](https://github.com/getsentry/sentry-java/pull/5759))
9+
- `sendDefaultPii` remains supported for backwards compatibility. When `dataCollection` is not configured, the SDK preserves the existing `sendDefaultPii` behavior.
10+
- Configuring any `dataCollection` option makes it the source of truth. `sendDefaultPii` is then ignored, and omitted `dataCollection` options use the defaults below.
11+
- The Logback appender is a compatibility exception. When an encoder is configured, `sendDefaultPii=true` continues to include the original message template and parameters. To opt in independently of `sendDefaultPii`, set `<includeUnencodedMessage>true</includeUnencodedMessage>` on the Sentry appender in `logback.xml` or `logback-spring.xml`.
12+
- Data explicitly supplied through APIs such as `Sentry.setUser`, scopes, event processors, or `beforeSend` is not affected.
13+
14+
To opt in to the documented `dataCollection` defaults without configuring an individual option:
15+
16+
```java
17+
Sentry.init(options -> options.getDataCollection().forceDataCollection());
18+
```
19+
20+
| Option | Default | Behavior |
21+
| --- | --- | --- |
22+
| `userInfo` | `true` | Allows integrations to populate user identity and IP address information automatically. |
23+
| `cookies` | `{ mode: DENY_LIST, terms: [] }` | Collects cookies while filtering sensitive values. |
24+
| `httpHeaders.request` | `{ mode: DENY_LIST, terms: [] }` | Collects request headers while filtering sensitive values. |
25+
| `httpHeaders.response` | `{ mode: DENY_LIST, terms: [] }` | Collects response headers while filtering sensitive values. |
26+
| `httpBodies` | All supported body types | Collects supported incoming and outgoing request and response bodies. An empty set disables body collection. |
27+
| `urlQueryParams` | `{ mode: DENY_LIST, terms: [] }` | Collects URL query parameters while filtering sensitive values. |
28+
| `graphql.document` | `true` | Collects GraphQL documents. |
29+
| `graphql.variables` | `true` | Collects GraphQL variables. |
30+
| `databaseQueryData` | `true` | Allows collection of associated query data, such as bound parameters, write payloads, and results, where supported. Sanitized query statements and structural database metadata remain available. |
31+
| `filePaths` | `true` | Allows file-system instrumentation to collect file and directory paths. File extensions and byte counts remain available when disabled. |
32+
33+
Cookies, HTTP headers, and URL query parameters support three modes:
34+
35+
- `OFF`: Do not collect the category.
36+
- `DENY_LIST`: Collect values except those matching the built-in sensitive deny-list or additional configured terms.
37+
- `ALLOW_LIST`: Only send plaintext values for matching terms. The built-in sensitive deny-list still applies.
38+
39+
Matching is case-insensitive and partial. The built-in sensitive deny-list contains `auth`, `token`, `secret`, `password`, `passwd`, `pwd`, `key`, `jwt`, `bearer`, `sso`, `saml`, `csrf`, `xsrf`, `credentials`, `session`, `sid`, and `identity`. Filtered values are replaced with `"[Filtered]"`. Custom deny-list terms extend rather than replace this list.
40+
41+
Configure all HTTP body types, a custom cookie deny-list, a request-header allow-list, and disable URL query parameter and file path collection in an options callback:
42+
43+
```java
44+
Sentry.init(
45+
options -> {
46+
options
47+
.getDataCollection()
48+
.setHttpBodies(
49+
EnumSet.of(
50+
HttpBodyType.INCOMING_REQUEST,
51+
HttpBodyType.OUTGOING_REQUEST,
52+
HttpBodyType.INCOMING_RESPONSE,
53+
HttpBodyType.OUTGOING_RESPONSE));
54+
options
55+
.getDataCollection()
56+
.setCookies(
57+
KeyValueCollectionBehavior.denyList(
58+
"forwarded", "-ip", "remote-", "via", "-user"));
59+
options
60+
.getDataCollection()
61+
.getHttpHeaders()
62+
.setRequest(
63+
KeyValueCollectionBehavior.allowList("content-type", "x-request-id"));
64+
options
65+
.getDataCollection()
66+
.setUrlQueryParams(KeyValueCollectionBehavior.off());
67+
options.getDataCollection().setFilePaths(false);
68+
});
69+
```
70+
71+
Configure the same options in `sentry.properties`:
72+
73+
```properties
74+
data-collection.http-bodies=incoming_request,outgoing_request,incoming_response,outgoing_response
75+
data-collection.cookies.mode=deny_list
76+
data-collection.cookies.terms=forwarded,-ip,remote-,via,-user
77+
data-collection.http-headers.request.mode=allow_list
78+
data-collection.http-headers.request.terms=content-type,x-request-id
79+
data-collection.url-query-params.mode=off
80+
data-collection.file-paths=false
81+
```
82+
83+
Configure them with Spring Boot properties:
84+
85+
```properties
86+
sentry.data-collection.http-bodies=incoming-request,outgoing-request,incoming-response,outgoing-response
87+
sentry.data-collection.cookies.mode=deny-list
88+
sentry.data-collection.cookies.terms=forwarded,-ip,remote-,via,-user
89+
sentry.data-collection.http-headers.request.mode=allow-list
90+
sentry.data-collection.http-headers.request.terms=content-type,x-request-id
91+
sentry.data-collection.url-query-params.mode=off
92+
sentry.data-collection.file-paths=false
93+
```
94+
95+
Configure them in `AndroidManifest.xml`:
96+
97+
```xml
98+
<meta-data
99+
android:name="io.sentry.data-collection.http-bodies"
100+
android:value="incoming_request,outgoing_request,incoming_response,outgoing_response" />
101+
<meta-data
102+
android:name="io.sentry.data-collection.cookies.mode"
103+
android:value="deny_list" />
104+
<meta-data
105+
android:name="io.sentry.data-collection.cookies.terms"
106+
android:value="forwarded,-ip,remote-,via,-user" />
107+
<meta-data
108+
android:name="io.sentry.data-collection.http-headers.request.mode"
109+
android:value="allow_list" />
110+
<meta-data
111+
android:name="io.sentry.data-collection.http-headers.request.terms"
112+
android:value="content-type,x-request-id" />
113+
<meta-data
114+
android:name="io.sentry.data-collection.url-query-params.mode"
115+
android:value="off" />
116+
<meta-data
117+
android:name="io.sentry.data-collection.file-paths"
118+
android:value="false" />
119+
```
120+
121+
See the [Data Collection documentation](https://docs.sentry.io/platforms/java/configuration/options/#dataCollection) for all configuration keys, supported integrations, and migration guidance.
122+
5123
### Fixes
6124

7125
- Disable URL caching when reading `META-INF/MANIFEST.MF` files during version detection so that the SDK no longer keeps jar file handles open for the life of the process ([#6124](https://github.com/getsentry/sentry-java/pull/6124)
126+
- Keep the `EventListener` wrapped by `SentryOkHttpEventListener` per `Call` ([#6003](https://github.com/getsentry/sentry-java/pull/6003))
8127

9128
## 8.57.0
10129

@@ -47,6 +166,7 @@
47166

48167
### Fixes
49168

169+
- Support `ws` and `wss` URL parsing for WebSocket instrumentation ([#6064](https://github.com/getsentry/sentry-java/pull/6064))
50170
- Keep resolving the server name after `Sentry.close()` or a re-init. Closing the SDK shut down the shared hostname cache for the life of the process, so `server_name` silently froze at the value it had last resolved ([#6119](https://github.com/getsentry/sentry-java/pull/6119))
51171
- Order breadcrumbs by the timestamp they carry rather than by when they were created in the current process, so breadcrumbs restored from disk or handed over by a hybrid SDK no longer sort as if they had just happened ([#6097](https://github.com/getsentry/sentry-java/pull/6097))
52172

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ public final class io/sentry/android/core/DeviceInfoUtil {
283283
public fun getSplitApksInfo ()Lio/sentry/android/core/ContextUtils$SplitApksInfo;
284284
public fun getTotalMemory ()Ljava/lang/Long;
285285
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
286-
public static fun resetInstance ()V
287286
}
288287

289288
public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : io/sentry/Integration, java/io/Closeable {

‎sentry-android-core/src/main/java/io/sentry/android/core/ApplicationExitInfoEventProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
681681
if (user.getId() == null) {
682682
user.setId(getDeviceId());
683683
}
684-
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
684+
if (user.getIpAddress() == null && options.getDataCollectionResolver().isUserInfo()) {
685685
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
686686
}
687687
}

‎sentry-android-core/src/main/java/io/sentry/android/core/DefaultAndroidEventProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
178178
if (user.getId() == null) {
179179
user.setId(Installation.id(context));
180180
}
181-
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
181+
if (user.getIpAddress() == null && options.getDataCollectionResolver().isUserInfo()) {
182182
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
183183
}
184184
}

‎sentry-android-core/src/main/java/io/sentry/android/core/DeviceInfoUtil.java‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
import android.os.SystemClock;
1616
import android.util.DisplayMetrics;
1717
import io.sentry.DateUtils;
18-
import io.sentry.ISentryLifecycleToken;
1918
import io.sentry.SentryLevel;
2019
import io.sentry.SentryOptions;
2120
import io.sentry.android.core.internal.util.CpuInfoUtils;
2221
import io.sentry.android.core.internal.util.DeviceOrientations;
2322
import io.sentry.android.core.internal.util.RootChecker;
2423
import io.sentry.protocol.Device;
2524
import io.sentry.protocol.OperatingSystem;
26-
import io.sentry.util.AutoClosableReentrantLock;
2725
import java.io.File;
2826
import java.util.Calendar;
2927
import java.util.Collections;
@@ -34,17 +32,10 @@
3432
import org.jetbrains.annotations.ApiStatus;
3533
import org.jetbrains.annotations.NotNull;
3634
import org.jetbrains.annotations.Nullable;
37-
import org.jetbrains.annotations.TestOnly;
3835

3936
@ApiStatus.Internal
4037
public final class DeviceInfoUtil {
4138

42-
@SuppressLint("StaticFieldLeak")
43-
private static volatile DeviceInfoUtil instance;
44-
45-
private static final @NotNull AutoClosableReentrantLock staticLock =
46-
new AutoClosableReentrantLock();
47-
4839
private final @NotNull Context context;
4940
private final @NotNull SentryAndroidOptions options;
5041
private final @NotNull BuildInfoProvider buildInfoProvider;
@@ -80,19 +71,7 @@ public DeviceInfoUtil(
8071
@NotNull
8172
public static DeviceInfoUtil getInstance(
8273
final @NotNull Context context, final @NotNull SentryAndroidOptions options) {
83-
if (instance == null) {
84-
try (final @NotNull ISentryLifecycleToken ignored = staticLock.acquire()) {
85-
if (instance == null) {
86-
instance = new DeviceInfoUtil(ContextUtils.getApplicationContext(context), options);
87-
}
88-
}
89-
}
90-
return instance;
91-
}
92-
93-
@TestOnly
94-
public static void resetInstance() {
95-
instance = null;
74+
return options.getOrCreateDeviceInfoUtil(context);
9675
}
9776

9877
// we can get some inspiration here

0 commit comments

Comments
 (0)