Skip to content

Commit 162ec3b

Browse files
committed
Merge branch 'main' into feat/more-detailed-e2e-assertions
2 parents 5f65fa7 + 10ae067 commit 162ec3b

File tree

15 files changed

+388
-102
lines changed

15 files changed

+388
-102
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,30 @@
44

55
### Fixes
66

7+
- Send Timber logs through Sentry Logs ([#4490](https://github.com/getsentry/sentry-java/pull/4490))
8+
- Enable the Logs feature in your `SentryOptions` or with the `io.sentry.logs.enabled` manifest option and the SDK will automatically send Timber logs to Sentry, if the TimberIntegration is enabled.
9+
- The SDK will automatically detect Timber and use it to send logs to Sentry.
10+
- Send logcat through Sentry Logs ([#4487](https://github.com/getsentry/sentry-java/pull/4487))
11+
- Enable the Logs feature in your `SentryOptions` or with the `io.sentry.logs.enabled` manifest option and the SDK will automatically send logcat logs to Sentry, if the Sentry Android Gradle plugin is applied.
12+
- To set the logcat level check the [Logcat integration documentation](https://docs.sentry.io/platforms/android/integrations/logcat/#configure).
13+
14+
### Dependencies
15+
16+
- Bump OpenTelemetry ([#4532](https://github.com/getsentry/sentry-java/pull/4532))
17+
- `opentelemetry-sdk` to `1.51.0`
18+
- `opentelemetry-instrumentation` to `2.17.0`
19+
- `opentelemetry-javaagent` to `2.17.0`
20+
- `opentelemetry-semconv` to `1.34.0`
21+
- We are now configuring OpenTelemetry to still behave the same way it did before for span names it generates in GraphQL auto instrumentation ([#4537](https://github.com/getsentry/sentry-java/pull/4537))
22+
23+
## 8.16.1-alpha.2
24+
25+
### Fixes
26+
727
- Optimize scope when maxBreadcrumb is 0 ([#4504](https://github.com/getsentry/sentry-java/pull/4504))
828
- Fix javadoc on TransportResult ([#4528](https://github.com/getsentry/sentry-java/pull/4528))
29+
- Session Replay: Fix `IllegalArgumentException` when `Bitmap` is initialized with non-positive values ([#4536](https://github.com/getsentry/sentry-java/pull/4536))
30+
- Set thread information on transaction from OpenTelemetry attributes ([#4478](https://github.com/getsentry/sentry-java/pull/4478))
931

1032
### Dependencies
1133

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.16.0
14+
versionName=8.16.1-alpha.2
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/SentryLogcatAdapter.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import android.util.Log;
44
import io.sentry.Breadcrumb;
5+
import io.sentry.ScopesAdapter;
56
import io.sentry.Sentry;
67
import io.sentry.SentryLevel;
8+
import io.sentry.SentryLogLevel;
79
import org.jetbrains.annotations.ApiStatus;
810
import org.jetbrains.annotations.NotNull;
911
import org.jetbrains.annotations.Nullable;
@@ -44,73 +46,104 @@ private static void addAsBreadcrumb(
4446
Sentry.addBreadcrumb(breadcrumb);
4547
}
4648

49+
private static void addAsLog(
50+
@NotNull final SentryLogLevel level,
51+
@Nullable final String msg,
52+
@Nullable final Throwable tr) {
53+
final @NotNull ScopesAdapter scopes = ScopesAdapter.getInstance();
54+
// Check if logs are enabled before doing expensive operations
55+
if (!scopes.getOptions().getLogs().isEnabled()) {
56+
return;
57+
}
58+
final @Nullable String trMessage = tr != null ? tr.getMessage() : null;
59+
if (tr == null || trMessage == null) {
60+
scopes.logger().log(level, msg);
61+
} else {
62+
scopes.logger().log(level, msg != null ? (msg + "\n" + trMessage) : trMessage);
63+
}
64+
}
65+
4766
public static int v(@Nullable String tag, @Nullable String msg) {
4867
addAsBreadcrumb(tag, SentryLevel.DEBUG, msg);
68+
addAsLog(SentryLogLevel.TRACE, msg, null);
4969
return Log.v(tag, msg);
5070
}
5171

5272
public static int v(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
5373
addAsBreadcrumb(tag, SentryLevel.DEBUG, msg, tr);
74+
addAsLog(SentryLogLevel.TRACE, msg, tr);
5475
return Log.v(tag, msg, tr);
5576
}
5677

5778
public static int d(@Nullable String tag, @Nullable String msg) {
5879
addAsBreadcrumb(tag, SentryLevel.DEBUG, msg);
80+
addAsLog(SentryLogLevel.DEBUG, msg, null);
5981
return Log.d(tag, msg);
6082
}
6183

6284
public static int d(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
6385
addAsBreadcrumb(tag, SentryLevel.DEBUG, msg, tr);
86+
addAsLog(SentryLogLevel.DEBUG, msg, tr);
6487
return Log.d(tag, msg, tr);
6588
}
6689

6790
public static int i(@Nullable String tag, @Nullable String msg) {
6891
addAsBreadcrumb(tag, SentryLevel.INFO, msg);
92+
addAsLog(SentryLogLevel.INFO, msg, null);
6993
return Log.i(tag, msg);
7094
}
7195

7296
public static int i(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
7397
addAsBreadcrumb(tag, SentryLevel.INFO, msg, tr);
98+
addAsLog(SentryLogLevel.INFO, msg, tr);
7499
return Log.i(tag, msg, tr);
75100
}
76101

77102
public static int w(@Nullable String tag, @Nullable String msg) {
78103
addAsBreadcrumb(tag, SentryLevel.WARNING, msg);
104+
addAsLog(SentryLogLevel.WARN, msg, null);
79105
return Log.w(tag, msg);
80106
}
81107

82108
public static int w(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
83109
addAsBreadcrumb(tag, SentryLevel.WARNING, msg, tr);
110+
addAsLog(SentryLogLevel.WARN, msg, tr);
84111
return Log.w(tag, msg, tr);
85112
}
86113

87114
public static int w(@Nullable String tag, @Nullable Throwable tr) {
88115
addAsBreadcrumb(tag, SentryLevel.WARNING, tr);
116+
addAsLog(SentryLogLevel.WARN, null, tr);
89117
return Log.w(tag, tr);
90118
}
91119

92120
public static int e(@Nullable String tag, @Nullable String msg) {
93121
addAsBreadcrumb(tag, SentryLevel.ERROR, msg);
122+
addAsLog(SentryLogLevel.ERROR, msg, null);
94123
return Log.e(tag, msg);
95124
}
96125

97126
public static int e(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
98127
addAsBreadcrumb(tag, SentryLevel.ERROR, msg, tr);
128+
addAsLog(SentryLogLevel.ERROR, msg, tr);
99129
return Log.e(tag, msg, tr);
100130
}
101131

102132
public static int wtf(@Nullable String tag, @Nullable String msg) {
103133
addAsBreadcrumb(tag, SentryLevel.ERROR, msg);
134+
addAsLog(SentryLogLevel.FATAL, msg, null);
104135
return Log.wtf(tag, msg);
105136
}
106137

107138
public static int wtf(@Nullable String tag, @Nullable Throwable tr) {
108139
addAsBreadcrumb(tag, SentryLevel.ERROR, tr);
140+
addAsLog(SentryLogLevel.FATAL, null, tr);
109141
return Log.wtf(tag, tr);
110142
}
111143

112144
public static int wtf(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
113145
addAsBreadcrumb(tag, SentryLevel.ERROR, msg, tr);
146+
addAsLog(SentryLogLevel.FATAL, msg, tr);
114147
return Log.wtf(tag, msg, tr);
115148
}
116149
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ class InternalSentrySdkTest {
269269

270270
// then modifications should not be reflected
271271
Sentry.configureScope { scope -> assertEquals(3, scope.breadcrumbs.size) }
272+
273+
// Ensure we don't interfere with other tests
274+
Sentry.configureScope(ScopeType.GLOBAL) { scope -> scope.clear() }
272275
}
273276

274277
@Test

0 commit comments

Comments
 (0)