Skip to content

Commit 1b983d5

Browse files
committed
Merge branch 'main' into feat/anr-native-symbolication
2 parents b1f58bf + 926429a commit 1b983d5

File tree

20 files changed

+380
-440
lines changed

20 files changed

+380
-440
lines changed

.craft.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ targets:
4343
maven:io.sentry:sentry-openfeign:
4444
maven:io.sentry:sentry-opentelemetry-agent:
4545
maven:io.sentry:sentry-opentelemetry-agentcustomization:
46+
maven:io.sentry:sentry-opentelemetry-agentless:
47+
maven:io.sentry:sentry-opentelemetry-agentless-spring:
48+
maven:io.sentry:sentry-opentelemetry-bootstrap:
4649
maven:io.sentry:sentry-opentelemetry-core:
47-
# maven:io.sentry:sentry-opentelemetry-agentless:
48-
# maven:io.sentry:sentry-opentelemetry-agentless-spring:
4950
maven:io.sentry:sentry-apollo:
5051
maven:io.sentry:sentry-jdbc:
5152
maven:io.sentry:sentry-graphql:
52-
# maven:io.sentry:sentry-graphql-core:
53-
# maven:io.sentry:sentry-graphql-22:
53+
maven:io.sentry:sentry-graphql-22:
54+
maven:io.sentry:sentry-graphql-core:
5455
maven:io.sentry:sentry-quartz:
5556
maven:io.sentry:sentry-okhttp:
5657
maven:io.sentry:sentry-android-navigation:

CHANGELOG.md

Lines changed: 199 additions & 321 deletions
Large diffs are not rendered by default.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android.useAndroidX=true
1313
android.defaults.buildfeatures.buildconfig=true
1414

1515
# Release information
16-
versionName=8.0.0-rc.4
16+
versionName=8.0.0
1717

1818
# Override the SDK name on native crashes on Android
1919
sentryAndroidSdkName=sentry.native.android

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
580580
if (user.getId() == null) {
581581
user.setId(getDeviceId());
582582
}
583-
if (user.getIpAddress() == null) {
583+
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
584584
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
585585
}
586586
}

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
@@ -156,7 +156,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
156156
if (user.getId() == null) {
157157
user.setId(Installation.id(context));
158158
}
159-
if (user.getIpAddress() == null) {
159+
if (user.getIpAddress() == null && options.isSendDefaultPii()) {
160160
user.setIpAddress(IpAddressUtils.DEFAULT_IP_ADDRESS);
161161
}
162162
}

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,20 @@ class AnrV2EventProcessorTest {
8585
lateinit var context: Context
8686
val options = SentryAndroidOptions().apply {
8787
setLogger(NoOpLogger.getInstance())
88-
isSendDefaultPii = true
8988
}
9089

9190
fun getSut(
9291
dir: TemporaryFolder,
9392
currentSdk: Int = Build.VERSION_CODES.LOLLIPOP,
9493
populateScopeCache: Boolean = false,
9594
populateOptionsCache: Boolean = false,
96-
replayErrorSampleRate: Double? = null
95+
replayErrorSampleRate: Double? = null,
96+
isSendDefaultPii: Boolean = true
9797
): AnrV2EventProcessor {
9898
options.cacheDirPath = dir.newFolder().absolutePath
9999
options.environment = "release"
100+
options.isSendDefaultPii = isSendDefaultPii
101+
100102
whenever(buildInfo.sdkInfoVersion).thenReturn(currentSdk)
101103
whenever(buildInfo.isEmulator).thenReturn(true)
102104

@@ -278,6 +280,7 @@ class AnrV2EventProcessorTest {
278280
// user
279281
assertEquals("bot", processed.user!!.username)
280282
assertEquals("[email protected]", processed.user!!.id)
283+
assertEquals("{{auto}}", processed.user!!.ipAddress)
281284
// trace
282285
assertEquals("ui.load", processed.contexts.trace!!.operation)
283286
// tags
@@ -304,6 +307,13 @@ class AnrV2EventProcessorTest {
304307
assertEquals("Google Chrome", processed.contexts.browser!!.name)
305308
}
306309

310+
@Test
311+
fun `when backfillable event is enrichable, does not backfill user ip`() {
312+
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
313+
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
314+
assertNull(processed.user!!.ipAddress)
315+
}
316+
307317
@Test
308318
fun `when backfillable event is enrichable, backfills serialized options data`() {
309319
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
@@ -617,14 +627,16 @@ class AnrV2EventProcessorTest {
617627
hint: Hint,
618628
populateScopeCache: Boolean = false,
619629
populateOptionsCache: Boolean = false,
630+
isSendDefaultPii: Boolean = true,
620631
configureEvent: SentryEvent.() -> Unit = {}
621632
): SentryEvent {
622633
val original = SentryEvent().apply(configureEvent)
623634

624635
val processor = fixture.getSut(
625636
tmpDir,
626637
populateScopeCache = populateScopeCache,
627-
populateOptionsCache = populateOptionsCache
638+
populateOptionsCache = populateOptionsCache,
639+
isSendDefaultPii = isSendDefaultPii
628640
)
629641
return processor.process(original, hint)!!
630642
}

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ class DefaultAndroidEventProcessorTest {
6666

6767
lateinit var sentryTracer: SentryTracer
6868

69-
fun getSut(context: Context): DefaultAndroidEventProcessor {
69+
fun getSut(
70+
context: Context,
71+
isSendDefaultPii: Boolean = false
72+
): DefaultAndroidEventProcessor {
73+
options.isSendDefaultPii = isSendDefaultPii
7074
whenever(scopes.options).thenReturn(options)
7175
sentryTracer = SentryTracer(TransactionContext("", ""), scopes)
7276
return DefaultAndroidEventProcessor(context, buildInfo, options)
@@ -284,8 +288,20 @@ class DefaultAndroidEventProcessorTest {
284288
}
285289

286290
@Test
287-
fun `when event user data does not have ip address set, sets {{auto}} as the ip address`() {
288-
val sut = fixture.getSut(context)
291+
fun `when event user data does not have ip address set, sets no ip address if sendDefaultPii is false`() {
292+
val sut = fixture.getSut(context, isSendDefaultPii = false)
293+
val event = SentryEvent().apply {
294+
user = User()
295+
}
296+
sut.process(event, Hint())
297+
assertNotNull(event.user) {
298+
assertNull(it.ipAddress)
299+
}
300+
}
301+
302+
@Test
303+
fun `when event user data does not have ip address set, sets {{auto}} if sendDefaultPii is true`() {
304+
val sut = fixture.getSut(context, isSendDefaultPii = true)
289305
val event = SentryEvent().apply {
290306
user = User()
291307
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ private SentryNdk() {}
2222
try {
2323
//noinspection UnstableApiUsage
2424
io.sentry.ndk.SentryNdk.loadNativeLibraries();
25+
} catch (Throwable t) {
26+
// ignored
27+
// if loadLibrary() fails, the later init() will throw an exception anyway
2528
} finally {
2629
loadLibraryLatch.countDown();
2730
}

sentry-opentelemetry/README.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# sentry-opentelemetry
22

3-
*NOTE: Our OpenTelemetry modules are still experimental. Any feedback is welcome.*
4-
53
## OpenTelemetry
64

75
More information on OpenTelemetry can be found on their [website](https://opentelemetry.io/) as well
@@ -21,8 +19,7 @@ application. Please see the module [README](sentry-opentelemetry-agent/README.md
2119

2220
This contains customizations to the OpenTelemetry Java Agent such as registering the
2321
`SentrySpanProcessor` and `SentryPropagator` as well as providing default properties that
24-
enable the `sentry` propagator and disable exporters so our agent doesn't trigger lots of log
25-
warnings due to OTLP server not being there. This can also be used without the agent.
22+
enable the `sentry` propagator.
2623

2724
### `sentry-opentelemetry-bootstrap`
2825

@@ -39,4 +36,50 @@ you also need this module as a dependency.
3936
Contains `SentrySpanProcessor` and `SentryPropagator` which are used by our Java Agent but can also
4037
be used when manually instrumenting using OpenTelemetry. If you want to use OpenTelemetry without
4138
the agent but still want some configuration convenience, you should rather use the
42-
`sentry-opentelemetry-agentcustomization` module.
39+
`sentry-opentelemetry-agentless` module or the `sentry-opentelemetry-agentless-spring` module if you are using Spring Boot.
40+
41+
### `sentry-opentelemetry-agentless`
42+
Combines all modules and dependencies needed to use Sentry with OpenTelemetry without the agent.
43+
44+
### `sentry-opentelemetry-agentless-spring`
45+
Combines all modules and dependencies needed to use Sentry with OpenTelemetry in Spring Boot without an agent.
46+
47+
## Running without an Agent
48+
If you want to use Sentry with OpenTelemetry without an agent, you can do so by adding the `sentry-opentelemetry-agentless` (or `sentry-opentelemetry-agentless-spring`) module as dependency to your project.
49+
50+
And run your application with the following JVM arguments:
51+
```
52+
-Dotel.java.global-autoconfigure.enabled=true
53+
```
54+
You may also want to set the following environment variables to if you do not use OpenTelemetry exporters:
55+
`OTEL_LOGS_EXPORTER=none;OTEL_METRICS_EXPORTER=none;OTEL_TRACES_EXPORTER=none`
56+
57+
Alternatively you can initialize OpenTelemetry programmatically like this:
58+
59+
```java
60+
// Initialize OpenTelemetry by using the AutoConfiguredOpenTelemetrySdk which automatically
61+
// registers the `SentrySpanProcessor` and `SentryPropagator` and others.
62+
// Also, you need to disable the OTEL exporters if you do not use them.
63+
AutoConfiguredOpenTelemetrySdk.builder()
64+
.setResultAsGlobal()
65+
.addPropertiesSupplier(() -> {
66+
final Map<String, String> properties = new HashMap<>();
67+
properties.put("otel.logs.exporter", "none");
68+
properties.put("otel.metrics.exporter", "none");
69+
properties.put("otel.traces.exporter", "none");
70+
return properties;
71+
})
72+
.build();
73+
```
74+
75+
And then initialize Sentry as usual:
76+
77+
```java
78+
// Initialize Sentry
79+
Sentry.init(
80+
options -> {
81+
options.setDsn("...");
82+
...
83+
}
84+
)
85+
```

sentry-opentelemetry/sentry-opentelemetry-agent/README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# sentry-opentelemetry-agent
22

3-
*NOTE: Our OpenTelemetry modules are still experimental. Any feedback is welcome.*
4-
53
## How to use it
64

75
Download the latest `sentry-opentelemetry-agent.jar` and use it when launching your Java
@@ -21,30 +19,24 @@ For more details on configuring Sentry via `sentry.properties` please see the
2119
[docs page](https://docs.sentry.io/platforms/java/configuration/).
2220

2321
As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual
24-
settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside
25-
your target application. If you do so, please make sure to set the `instrumenter` to `otel`, e.g.
26-
like this:
22+
settings as environment variables (e.g. `SENTRY_DSN=...`).
23+
24+
## Controlling auto initialization of Sentry
25+
26+
By default, if you pass either `SENTRY_DSN` or `SENTRY_PROPERTIES_FILE` as environment variable,
27+
Sentry will automatically be initialized by this agent. To disable this behaviour, you can set
28+
`SENTRY_AUTO_INIT=false` as environment variable. You will then have to use a Sentry SDK that takes care of initialization or initialize Sentry manually inside
29+
the target application:
2730

2831
```
2932
Sentry.init(
3033
options -> {
3134
options.setDsn("...");
3235
...
33-
options.setInstrumenter(Instrumenter.OTEL);
3436
}
3537
)
3638
```
3739

38-
Using the `otel` instrumenter will ensure `Sentry` instrumentation will be done via OpenTelemetry
39-
and integrations as well as direct interactions with transactions and spans have no effect.
40-
41-
## Controlling auto initialization of Sentry
42-
43-
By default if you pass either `SENTRY_DSN` or `SENTRY_PROPERTIES_FILE` as environment variable,
44-
Sentry will automatically be initialized by this agent. To disable this behaviour, you can set
45-
`SENTRY_AUTO_INIT=false` as environment variable. You will then have to initialize Sentry inside
46-
the target application.
47-
4840
## Debugging
4941

5042
To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or
@@ -62,6 +54,7 @@ Example log message:
6254
```
6355
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export spans. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
6456
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export metrics. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
57+
ERROR io.opentelemetry.exporter.internal.http.HttpExporter - Failed to export logs. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4318
6558
```
6659

6760
### Traces
@@ -73,3 +66,8 @@ see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/
7366

7467
To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none`
7568
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
69+
70+
### Logs
71+
72+
To turn off log exporting, set `OTEL_LOGS_EXPORTER=none`
73+
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters).

0 commit comments

Comments
 (0)