Skip to content

Commit b2b6047

Browse files
committed
Merge branch 'main' into feat/log4j2-logs
2 parents 0bd63c4 + 12f6380 commit b2b6047

File tree

10 files changed

+85
-12
lines changed

10 files changed

+85
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

3-
## Unreleased
3+
## 8.15.1
4+
5+
### Fixes
6+
7+
- Enabling Sentry Logs through Logback in Spring Boot config did not work in 3.15.0 ([#4523](https://github.com/getsentry/sentry-java/pull/4523))
8+
9+
## 8.15.0
410

511
### Features
612

@@ -13,6 +19,7 @@
1319
- Log parameter objects are now turned into `String` via `toString` ([#4515](https://github.com/getsentry/sentry-java/pull/4515))
1420
- One of the two `SentryLogEventAttributeValue` constructors did not convert the value previously.
1521
- Logs are now flushed on shutdown ([#4503](https://github.com/getsentry/sentry-java/pull/4503))
22+
- User Feedback: Do not redefine system attributes for `SentryUserFeedbackButton`, but reference them instead ([#4519](https://github.com/getsentry/sentry-java/pull/4519))
1623

1724
### Features
1825

@@ -52,6 +59,7 @@
5259
```properties
5360
logs.enabled=true
5461
```
62+
- Automatically use `SentryOptions.Logs.BeforeSendLogCallback` Spring beans ([#4509](https://github.com/getsentry/sentry-java/pull/4509))
5563

5664
### Dependencies
5765

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
1111
android.useAndroidX=true
1212

1313
# Release information
14-
versionName=8.14.0
14+
versionName=8.15.1
1515

1616
# Override the SDK name on native crashes on Android
1717
sentryAndroidSdkName=sentry.native.android

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.sentry.IScopes;
1313
import io.sentry.Sentry;
1414
import io.sentry.SentryFeedbackOptions;
15+
import io.sentry.SentryIntegrationPackageStorage;
1516
import io.sentry.SentryLevel;
1617
import io.sentry.SentryOptions;
1718
import io.sentry.protocol.Feedback;
@@ -34,6 +35,7 @@ public final class SentryUserFeedbackDialog extends AlertDialog {
3435
final @Nullable OptionsConfiguration configuration) {
3536
super(context, themeResId);
3637
this.configuration = configuration;
38+
SentryIntegrationPackageStorage.getInstance().addIntegration("UserFeedbackWidget");
3739
}
3840

3941
@Override
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<!-- We have to omit 'format' here as we're referencing the system attributes from the '@android:' namespace -->
34
<declare-styleable name="SentryUserFeedbackButton" >
4-
<attr name="android:drawableStart" format="reference" />
5-
<attr name="android:drawablePadding" format="dimension" />
6-
<attr name="android:padding" format="dimension" />
7-
<attr name="android:textAllCaps" format="boolean" />
8-
<attr name="android:background" format="reference|color" />
9-
<attr name="android:textColor" format="reference|color" />
10-
<attr name="android:text" format="string" />
5+
<attr name="android:drawableStart" />
6+
<attr name="android:drawablePadding" />
7+
<attr name="android:padding" />
8+
<attr name="android:textAllCaps" />
9+
<attr name="android:background" />
10+
<attr name="android:textColor" />
11+
<attr name="android:text" />
1112
</declare-styleable>
1213
</resources>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources xmlns:tools="http://schemas.android.com/tools">
3+
<!-- Just a dummy styleable to verify resource merging -->
4+
<declare-styleable name="DummyStyle" >
5+
<attr name="android:drawableStart" format="reference" />
6+
<attr name="android:drawablePadding" format="dimension" />
7+
<attr name="android:padding" format="dimension" />
8+
<attr name="android:textAllCaps" format="boolean" />
9+
<attr name="android:background" format="reference|color" />
10+
<attr name="android:textColor" format="reference|color" />
11+
<attr name="android:text" format="string" />
12+
</declare-styleable>
13+
314
<bool tools:ignore="UnusedResources" name="leak_canary_allow_in_non_debuggable_build">true</bool>
415
</resources>

sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public void start() {
8383

8484
@Override
8585
protected void append(@NotNull ILoggingEvent eventObject) {
86-
if (options.getLogs().isEnabled() && eventObject.getLevel().isGreaterOrEqual(minimumLevel)) {
86+
if (ScopesAdapter.getInstance().getOptions().getLogs().isEnabled()
87+
&& eventObject.getLevel().isGreaterOrEqual(minimumLevel)) {
8788
captureLog(eventObject);
8889
}
8990
if (eventObject.getLevel().isGreaterOrEqual(minimumEventLevel)) {
@@ -113,7 +114,7 @@ protected void append(@NotNull ILoggingEvent eventObject) {
113114
final Message message = new Message();
114115

115116
// if encoder is set we treat message+params as PII as encoders may be used to mask/strip PII
116-
if (encoder == null || options.isSendDefaultPii()) {
117+
if (encoder == null || ScopesAdapter.getInstance().getOptions().isSendDefaultPii()) {
117118
message.setMessage(loggingEvent.getMessage());
118119
message.setParams(toParams(loggingEvent.getArgumentArray()));
119120
}
@@ -184,7 +185,7 @@ protected void captureLog(@NotNull ILoggingEvent loggingEvent) {
184185
final @NotNull SentryAttributes attributes = SentryAttributes.of();
185186

186187
// if encoder is set we treat message+params as PII as encoders may be used to mask/strip PII
187-
if (encoder == null || options.isSendDefaultPii()) {
188+
if (encoder == null || ScopesAdapter.getInstance().getOptions().isSendDefaultPii()) {
188189
attributes.add(
189190
SentryAttribute.stringAttribute("sentry.message.template", loggingEvent.getMessage()));
190191
arguments = loggingEvent.getArgumentArray();

sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ static class HubConfiguration {
103103
final @NotNull ObjectProvider<SentryOptions.BeforeSendCallback> beforeSendCallback,
104104
final @NotNull ObjectProvider<SentryOptions.BeforeSendTransactionCallback>
105105
beforeSendTransactionCallback,
106+
final @NotNull ObjectProvider<SentryOptions.Logs.BeforeSendLogCallback>
107+
beforeSendLogsCallback,
106108
final @NotNull ObjectProvider<SentryOptions.BeforeBreadcrumbCallback>
107109
beforeBreadcrumbCallback,
108110
final @NotNull ObjectProvider<SentryOptions.TracesSamplerCallback> tracesSamplerCallback,
@@ -114,6 +116,7 @@ static class HubConfiguration {
114116
return options -> {
115117
beforeSendCallback.ifAvailable(options::setBeforeSend);
116118
beforeSendTransactionCallback.ifAvailable(options::setBeforeSendTransaction);
119+
beforeSendLogsCallback.ifAvailable(callback -> options.getLogs().setBeforeSend(callback));
117120
beforeBreadcrumbCallback.ifAvailable(options::setBeforeBreadcrumb);
118121
tracesSamplerCallback.ifAvailable(options::setTracesSampler);
119122
eventProcessors.forEach(options::addEventProcessor);

sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.sentry.Sentry
1616
import io.sentry.SentryEvent
1717
import io.sentry.SentryIntegrationPackageStorage
1818
import io.sentry.SentryLevel
19+
import io.sentry.SentryLogEvent
1920
import io.sentry.SentryOptions
2021
import io.sentry.checkEvent
2122
import io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider
@@ -350,6 +351,17 @@ class SentryAutoConfigurationTest {
350351
}
351352
}
352353

354+
@Test
355+
fun `registers logs beforeSendCallback on SentryOptions`() {
356+
contextRunner
357+
.withPropertyValues("sentry.dsn=http://key@localhost/proj")
358+
.withUserConfiguration(CustomBeforeSendLogsCallbackConfiguration::class.java)
359+
.run {
360+
assertThat(it.getBean(SentryOptions::class.java).logs.beforeSend)
361+
.isInstanceOf(CustomBeforeSendLogsCallback::class.java)
362+
}
363+
}
364+
353365
@Test
354366
fun `registers beforeBreadcrumbCallback on SentryOptions`() {
355367
contextRunner
@@ -1095,6 +1107,16 @@ class SentryAutoConfigurationTest {
10951107
override fun execute(event: SentryEvent, hint: Hint): SentryEvent? = null
10961108
}
10971109

1110+
@Configuration(proxyBeanMethods = false)
1111+
open class CustomBeforeSendLogsCallbackConfiguration {
1112+
1113+
@Bean open fun beforeSendCallback() = CustomBeforeSendLogsCallback()
1114+
}
1115+
1116+
class CustomBeforeSendLogsCallback : SentryOptions.Logs.BeforeSendLogCallback {
1117+
override fun execute(event: SentryLogEvent): SentryLogEvent? = null
1118+
}
1119+
10981120
@Configuration(proxyBeanMethods = false)
10991121
open class CustomBeforeSendTransactionCallbackConfiguration {
11001122

sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ static class HubConfiguration {
101101
final @NotNull ObjectProvider<SentryOptions.BeforeSendCallback> beforeSendCallback,
102102
final @NotNull ObjectProvider<SentryOptions.BeforeSendTransactionCallback>
103103
beforeSendTransactionCallback,
104+
final @NotNull ObjectProvider<SentryOptions.Logs.BeforeSendLogCallback>
105+
beforeSendLogsCallback,
104106
final @NotNull ObjectProvider<SentryOptions.BeforeBreadcrumbCallback>
105107
beforeBreadcrumbCallback,
106108
final @NotNull ObjectProvider<SentryOptions.TracesSamplerCallback> tracesSamplerCallback,
@@ -112,6 +114,7 @@ static class HubConfiguration {
112114
return options -> {
113115
beforeSendCallback.ifAvailable(options::setBeforeSend);
114116
beforeSendTransactionCallback.ifAvailable(options::setBeforeSendTransaction);
117+
beforeSendLogsCallback.ifAvailable(callback -> options.getLogs().setBeforeSend(callback));
115118
beforeBreadcrumbCallback.ifAvailable(options::setBeforeBreadcrumb);
116119
tracesSamplerCallback.ifAvailable(options::setTracesSampler);
117120
eventProcessors.forEach(options::addEventProcessor);

sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.sentry.Sentry
1616
import io.sentry.SentryEvent
1717
import io.sentry.SentryIntegrationPackageStorage
1818
import io.sentry.SentryLevel
19+
import io.sentry.SentryLogEvent
1920
import io.sentry.SentryOptions
2021
import io.sentry.checkEvent
2122
import io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider
@@ -338,6 +339,17 @@ class SentryAutoConfigurationTest {
338339
}
339340
}
340341

342+
@Test
343+
fun `registers logs beforeSendCallback on SentryOptions`() {
344+
contextRunner
345+
.withPropertyValues("sentry.dsn=http://key@localhost/proj")
346+
.withUserConfiguration(CustomBeforeSendLogsCallbackConfiguration::class.java)
347+
.run {
348+
assertThat(it.getBean(SentryOptions::class.java).logs.beforeSend)
349+
.isInstanceOf(CustomBeforeSendLogsCallback::class.java)
350+
}
351+
}
352+
341353
@Test
342354
fun `registers beforeSendTransactionCallback on SentryOptions`() {
343355
contextRunner
@@ -1021,6 +1033,16 @@ class SentryAutoConfigurationTest {
10211033
override fun execute(event: SentryEvent, hint: Hint): SentryEvent? = null
10221034
}
10231035

1036+
@Configuration(proxyBeanMethods = false)
1037+
open class CustomBeforeSendLogsCallbackConfiguration {
1038+
1039+
@Bean open fun beforeSendCallback() = CustomBeforeSendLogsCallback()
1040+
}
1041+
1042+
class CustomBeforeSendLogsCallback : SentryOptions.Logs.BeforeSendLogCallback {
1043+
override fun execute(event: SentryLogEvent): SentryLogEvent? = null
1044+
}
1045+
10241046
@Configuration(proxyBeanMethods = false)
10251047
open class CustomBeforeSendTransactionCallbackConfiguration {
10261048

0 commit comments

Comments
 (0)