Skip to content

Commit 55df841

Browse files
committed
Merge branch 'main' into ref/android-16-target-sdk
2 parents 1410a4e + 96eeafa commit 55df841

File tree

11 files changed

+221
-12
lines changed

11 files changed

+221
-12
lines changed

.claude/settings.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(find:*)",
5+
"Bash(ls:*)",
6+
"Bash(git:*)",
7+
"Bash(git status:*)",
8+
"Bash(git log:*)",
9+
"Bash(git diff:*)",
10+
"Bash(git show:*)",
11+
"Bash(git branch:*)",
12+
"Bash(git remote:*)",
13+
"Bash(git tag:*)",
14+
"Bash(git stash list:*)",
15+
"Bash(git rev-parse:*)",
16+
"Bash(gh pr view:*)",
17+
"Bash(gh pr list:*)",
18+
"Bash(gh pr checks:*)",
19+
"Bash(gh pr diff:*)",
20+
"Bash(gh issue view:*)",
21+
"Bash(gh issue list:*)",
22+
"Bash(gh run view:*)",
23+
"Bash(gh run list:*)",
24+
"Bash(gh run logs:*)",
25+
"Bash(gh repo view:*)",
26+
"WebFetch(domain:github.com)",
27+
"WebFetch(domain:docs.sentry.io)",
28+
"WebFetch(domain:develop.sentry.dev)",
29+
"Bash(grep:*)",
30+
"Bash(mv:*)"
31+
],
32+
"deny": []
33+
}
34+
}

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
# Changelog
22

3-
## Unreleased
3+
# Unreleased
4+
5+
### Improvements
6+
7+
- Update Android targetSdk to API 36 (Android 16) ([#5016](https://github.com/getsentry/sentry-java/pull/5016))
8+
9+
## 8.31.0
410

511
### Features
612

713
- Added `io.sentry.ndk.sdk-name` Android manifest option to configure the native SDK's name ([#5027](https://github.com/getsentry/sentry-java/pull/5027))
14+
- Replace `sentry.trace.parent_span_id` attribute with `spanId` property on `SentryLogEvent` ([#5040](https://github.com/getsentry/sentry-java/pull/5040))
15+
16+
### Fixes
17+
18+
- Only attach user attributes to logs if `sendDefaultPii` is enabled ([#5036](https://github.com/getsentry/sentry-java/pull/5036))
19+
- Reject new logs if `LoggerBatchProcessor` is shutting down ([#5041](https://github.com/getsentry/sentry-java/pull/5041))
20+
- Downgrade protobuf-javalite dependency from 4.33.1 to 3.25.8 ([#5044](https://github.com/getsentry/sentry-java/pull/5044))
821

922
### Dependencies
1023

@@ -24,7 +37,6 @@
2437

2538
### Improvements
2639

27-
- Update Android targetSdk to API 36 (Android 16) ([#5016](https://github.com/getsentry/sentry-java/pull/5016))
2840
- Expose `MAX_EVENT_SIZE_BYTES` constant in SentryOptions ([#4962](https://github.com/getsentry/sentry-java/pull/4962))
2941
- Discard envelopes on `4xx` and `5xx` response ([#4950](https://github.com/getsentry/sentry-java/pull/4950))
3042
- This aims to not overwhelm Sentry after an outage or load shedding (including HTTP 429) where too many events are sent at once

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.30.0
14+
versionName=8.31.0
1515

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

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spotless = "7.0.4"
4141
gummyBears = "0.12.0"
4242
camerax = "1.3.0"
4343
openfeature = "1.18.2"
44-
protobuf = "4.33.1"
44+
protobuf = "3.25.8"
4545

4646
[plugins]
4747
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

sentry/api/sentry.api

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,15 +3238,19 @@ public final class io/sentry/SentryLogEvent : io/sentry/JsonSerializable, io/sen
32383238
public fun getBody ()Ljava/lang/String;
32393239
public fun getLevel ()Lio/sentry/SentryLogLevel;
32403240
public fun getSeverityNumber ()Ljava/lang/Integer;
3241+
public fun getSpanId ()Lio/sentry/SpanId;
32413242
public fun getTimestamp ()Ljava/lang/Double;
3243+
public fun getTraceId ()Lio/sentry/protocol/SentryId;
32423244
public fun getUnknown ()Ljava/util/Map;
32433245
public fun serialize (Lio/sentry/ObjectWriter;Lio/sentry/ILogger;)V
32443246
public fun setAttribute (Ljava/lang/String;Lio/sentry/SentryLogEventAttributeValue;)V
32453247
public fun setAttributes (Ljava/util/Map;)V
32463248
public fun setBody (Ljava/lang/String;)V
32473249
public fun setLevel (Lio/sentry/SentryLogLevel;)V
32483250
public fun setSeverityNumber (Ljava/lang/Integer;)V
3251+
public fun setSpanId (Lio/sentry/SpanId;)V
32493252
public fun setTimestamp (Ljava/lang/Double;)V
3253+
public fun setTraceId (Lio/sentry/protocol/SentryId;)V
32503254
public fun setUnknown (Ljava/util/Map;)V
32513255
}
32523256

@@ -3261,6 +3265,7 @@ public final class io/sentry/SentryLogEvent$JsonKeys {
32613265
public static final field BODY Ljava/lang/String;
32623266
public static final field LEVEL Ljava/lang/String;
32633267
public static final field SEVERITY_NUMBER Ljava/lang/String;
3268+
public static final field SPAN_ID Ljava/lang/String;
32643269
public static final field TIMESTAMP Ljava/lang/String;
32653270
public static final field TRACE_ID Ljava/lang/String;
32663271
public fun <init> ()V

sentry/src/main/java/io/sentry/SentryLogEvent.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public final class SentryLogEvent implements JsonUnknown, JsonSerializable {
1414

1515
private @NotNull SentryId traceId;
16+
private @Nullable SpanId spanId;
1617
private @NotNull Double timestamp;
1718
private @NotNull String body;
1819
private @NotNull SentryLogLevel level;
@@ -92,10 +93,27 @@ public void setSeverityNumber(final @Nullable Integer severityNumber) {
9293
this.severityNumber = severityNumber;
9394
}
9495

96+
public @Nullable SpanId getSpanId() {
97+
return spanId;
98+
}
99+
100+
public void setSpanId(final @Nullable SpanId spanId) {
101+
this.spanId = spanId;
102+
}
103+
104+
public @NotNull SentryId getTraceId() {
105+
return traceId;
106+
}
107+
108+
public void setTraceId(final @NotNull SentryId traceId) {
109+
this.traceId = traceId;
110+
}
111+
95112
// region json
96113
public static final class JsonKeys {
97114
public static final String TIMESTAMP = "timestamp";
98115
public static final String TRACE_ID = "trace_id";
116+
public static final String SPAN_ID = "span_id";
99117
public static final String LEVEL = "level";
100118
public static final String SEVERITY_NUMBER = "severity_number";
101119
public static final String BODY = "body";
@@ -109,6 +127,9 @@ public void serialize(final @NotNull ObjectWriter writer, final @NotNull ILogger
109127
writer.beginObject();
110128
writer.name(JsonKeys.TIMESTAMP).value(logger, doubleToBigDecimal(timestamp));
111129
writer.name(JsonKeys.TRACE_ID).value(logger, traceId);
130+
if (spanId != null) {
131+
writer.name(JsonKeys.SPAN_ID).value(logger, spanId);
132+
}
112133
writer.name(JsonKeys.BODY).value(body);
113134
writer.name(JsonKeys.LEVEL).value(logger, level);
114135
if (severityNumber != null) {
@@ -145,6 +166,7 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
145166
final @NotNull ObjectReader reader, final @NotNull ILogger logger) throws Exception {
146167
@Nullable Map<String, Object> unknown = null;
147168
@Nullable SentryId traceId = null;
169+
@Nullable SpanId spanId = null;
148170
@Nullable Double timestamp = null;
149171
@Nullable String body = null;
150172
@Nullable SentryLogLevel level = null;
@@ -158,6 +180,9 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
158180
case JsonKeys.TRACE_ID:
159181
traceId = reader.nextOrNull(logger, new SentryId.Deserializer());
160182
break;
183+
case JsonKeys.SPAN_ID:
184+
spanId = reader.nextOrNull(logger, new SpanId.Deserializer());
185+
break;
161186
case JsonKeys.TIMESTAMP:
162187
timestamp = reader.nextDoubleOrNull();
163188
break;
@@ -216,6 +241,7 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
216241

217242
logEvent.setAttributes(attributes);
218243
logEvent.setSeverityNumber(severityNumber);
244+
logEvent.setSpanId(spanId);
219245
logEvent.setUnknown(unknown);
220246

221247
return logEvent;

sentry/src/main/java/io/sentry/logger/LoggerApi.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ private void captureLog(
131131
span == null ? propagationContext.getSpanId() : span.getSpanContext().getSpanId();
132132
final SentryLogEvent logEvent =
133133
new SentryLogEvent(traceId, timestampToUse, messageToUse, level);
134-
logEvent.setAttributes(createAttributes(params, message, spanId, args));
134+
logEvent.setSpanId(spanId);
135+
logEvent.setAttributes(createAttributes(params, message, args));
135136
logEvent.setSeverityNumber(level.getSeverityNumber());
136137

137138
scopes.getClient().captureLog(logEvent, combinedScope);
@@ -160,7 +161,6 @@ private void captureLog(
160161
private @NotNull HashMap<String, SentryLogEventAttributeValue> createAttributes(
161162
final @NotNull SentryLogParameters params,
162163
final @NotNull String message,
163-
final @NotNull SpanId spanId,
164164
final @Nullable Object... args) {
165165
final @NotNull HashMap<String, SentryLogEventAttributeValue> attributes = new HashMap<>();
166166
final @NotNull String origin = params.getOrigin();
@@ -239,15 +239,13 @@ private void captureLog(
239239
"sentry.release", new SentryLogEventAttributeValue(SentryAttributeType.STRING, release));
240240
}
241241

242-
attributes.put(
243-
"sentry.trace.parent_span_id",
244-
new SentryLogEventAttributeValue(SentryAttributeType.STRING, spanId));
245-
246242
if (Platform.isJvm()) {
247243
setServerName(attributes);
248244
}
249245

250-
setUser(attributes);
246+
if (scopes.getOptions().isSendDefaultPii()) {
247+
setUser(attributes);
248+
}
251249

252250
return attributes;
253251
}

sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class LoggerBatchProcessor implements ILoggerBatchProcessor {
3838
private volatile @Nullable Future<?> scheduledFlush;
3939
private final @NotNull AutoClosableReentrantLock scheduleLock = new AutoClosableReentrantLock();
4040
private volatile boolean hasScheduled = false;
41+
private volatile boolean isShuttingDown = false;
4142

4243
private final @NotNull ReusableCountLatch pendingCount = new ReusableCountLatch();
4344

@@ -51,6 +52,9 @@ public LoggerBatchProcessor(
5152

5253
@Override
5354
public void add(final @NotNull SentryLogEvent logEvent) {
55+
if (isShuttingDown) {
56+
return;
57+
}
5458
if (pendingCount.getCount() >= MAX_QUEUE_SIZE) {
5559
options
5660
.getClientReportRecorder()
@@ -70,6 +74,7 @@ public void add(final @NotNull SentryLogEvent logEvent) {
7074
@SuppressWarnings("FutureReturnValueIgnored")
7175
@Override
7276
public void close(final boolean isRestarting) {
77+
isShuttingDown = true;
7378
if (isRestarting) {
7479
maybeSchedule(true, true);
7580
executorService.submit(() -> executorService.close(options.getShutdownTimeoutMillis()));

0 commit comments

Comments
 (0)