Skip to content

Commit 6019d9c

Browse files
authored
Merge branch 'main' into lcian/feat/report-build-tool
2 parents bea3859 + 10ae067 commit 6019d9c

File tree

14 files changed

+358
-150
lines changed

14 files changed

+358
-150
lines changed

CHANGELOG.md

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

55
### Features
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).
713
- Read build tool info from `sentry-debug-meta.properties` and attach it to events ([#4314](https://github.com/getsentry/sentry-java/pull/4314))
814

15+
### Dependencies
16+
17+
- Bump OpenTelemetry ([#4532](https://github.com/getsentry/sentry-java/pull/4532))
18+
- `opentelemetry-sdk` to `1.51.0`
19+
- `opentelemetry-instrumentation` to `2.17.0`
20+
- `opentelemetry-javaagent` to `2.17.0`
21+
- `opentelemetry-semconv` to `1.34.0`
22+
- 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))
23+
924
## 8.16.1-alpha.2
1025

1126
### Fixes

gradle/libs.versions.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ nopen = "1.0.1"
1919
# see https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html#kotlin-compatibility
2020
# see https://developer.android.com/jetpack/androidx/releases/compose-kotlin
2121
okhttp = "4.9.2"
22-
otel = "1.44.1"
23-
otelInstrumentation = "2.10.0"
24-
otelInstrumentationAlpha = "2.10.0-alpha"
22+
otel = "1.51.0"
23+
otelInstrumentation = "2.17.0"
24+
otelInstrumentationAlpha = "2.17.0-alpha"
2525
# check https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/dependencyManagement/build.gradle.kts#L49 for release version above to find a compatible version
26-
otelSemanticConventions = "1.28.0-alpha"
26+
otelSemanticConventions = "1.34.0"
27+
otelSemanticConventionsAlpha = "1.34.0-alpha"
2728
retrofit = "2.9.0"
2829
slf4j = "1.7.30"
2930
springboot2 = "2.7.18"
@@ -110,7 +111,7 @@ otel-javaagent = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent"
110111
otel-javaagent-tooling = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling", version.ref = "otelInstrumentationAlpha" }
111112
otel-javaagent-extension-api = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api", version.ref = "otelInstrumentationAlpha" }
112113
otel-semconv = { module = "io.opentelemetry.semconv:opentelemetry-semconv", version.ref = "otelSemanticConventions" }
113-
otel-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "otelSemanticConventions" }
114+
otel-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "otelSemanticConventionsAlpha" }
114115
p6spy = { module = "p6spy:p6spy", version = "3.9.1" }
115116
quartz = { module = "org.quartz-scheduler:quartz", version = "2.3.0" }
116117
reactor-core = { module = "io.projectreactor:reactor-core", version = "3.5.3" }

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)