Skip to content

Commit bc7687e

Browse files
authored
Merge branch 'main' into feat/bump-otel-1_51_0
2 parents 81aa960 + f43539f commit bc7687e

File tree

7 files changed

+72
-3
lines changed

7 files changed

+72
-3
lines changed

CHANGELOG.md

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

3-
## Unreleased
3+
## 8.16.1-alpha.2
44

55
### Fixes
66

77
- Optimize scope when maxBreadcrumb is 0 ([#4504](https://github.com/getsentry/sentry-java/pull/4504))
88
- Fix javadoc on TransportResult ([#4528](https://github.com/getsentry/sentry-java/pull/4528))
9+
- Session Replay: Fix `IllegalArgumentException` when `Bitmap` is initialized with non-positive values ([#4536](https://github.com/getsentry/sentry-java/pull/4536))
10+
- Set thread information on transaction from OpenTelemetry attributes ([#4478](https://github.com/getsentry/sentry-java/pull/4478))
911

1012
### Dependencies
1113

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-replay/src/main/java/io/sentry/android/replay/util/Views.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,4 @@ internal fun View?.removeOnPreDrawListenerSafe(listener: ViewTreeObserver.OnPreD
245245
}
246246
}
247247

248-
internal fun View.hasSize(): Boolean = width != 0 && height != 0
248+
internal fun View.hasSize(): Boolean = width > 0 && height > 0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.sentry.android.replay.util
2+
3+
import android.view.View
4+
import androidx.test.core.app.ApplicationProvider
5+
import androidx.test.ext.junit.runners.AndroidJUnit4
6+
import kotlin.test.Test
7+
import kotlin.test.assertFalse
8+
import kotlin.test.assertTrue
9+
import org.junit.runner.RunWith
10+
11+
@RunWith(AndroidJUnit4::class)
12+
class ViewsTest {
13+
@Test
14+
fun `hasSize returns true for positive values`() {
15+
val view = View(ApplicationProvider.getApplicationContext())
16+
view.right = 100
17+
view.bottom = 100
18+
assertTrue(view.hasSize())
19+
}
20+
21+
@Test
22+
fun `hasSize returns false for null values`() {
23+
val view = View(ApplicationProvider.getApplicationContext())
24+
view.right = 0
25+
view.bottom = 0
26+
assertFalse(view.hasSize())
27+
}
28+
29+
@Test
30+
fun `hasSize returns false for negative values`() {
31+
val view = View(ApplicationProvider.getApplicationContext())
32+
view.right = -1
33+
view.bottom = -1
34+
assertFalse(view.hasSize())
35+
}
36+
}

sentry-opentelemetry/sentry-opentelemetry-core/api/sentry-opentelemetry-core.api

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public final class io/sentry/opentelemetry/OtelSpanInfo {
5050
public fun getTransactionNameSource ()Lio/sentry/protocol/TransactionNameSource;
5151
}
5252

53+
public final class io/sentry/opentelemetry/OtelSpanUtils {
54+
public fun <init> ()V
55+
public static fun maybeTransferOtelAttribute (Lio/opentelemetry/sdk/trace/data/SpanData;Lio/sentry/ISpan;Lio/opentelemetry/api/common/AttributeKey;)V
56+
}
57+
5358
public final class io/sentry/opentelemetry/OtelSpanWrapper : io/sentry/opentelemetry/IOtelSpanWrapper {
5459
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/IScopes;Lio/sentry/SentryDate;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/IOtelSpanWrapper;Lio/sentry/SpanId;Lio/sentry/Baggage;)V
5560
public fun finish ()V
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.sentry.opentelemetry;
2+
3+
import io.opentelemetry.api.common.AttributeKey;
4+
import io.opentelemetry.api.common.Attributes;
5+
import io.opentelemetry.sdk.trace.data.SpanData;
6+
import io.sentry.ISpan;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
9+
10+
public final class OtelSpanUtils {
11+
public static <T> void maybeTransferOtelAttribute(
12+
final @NotNull SpanData otelSpan,
13+
final @NotNull ISpan sentrySpan,
14+
final @NotNull AttributeKey<T> key) {
15+
final @NotNull Attributes attributes = otelSpan.getAttributes();
16+
final @Nullable T value = attributes.get(key);
17+
if (value != null) {
18+
sentrySpan.setData(key.getKey(), value);
19+
}
20+
}
21+
}

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SentrySpanExporter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static io.sentry.TransactionContext.DEFAULT_TRANSACTION_NAME;
44
import static io.sentry.opentelemetry.InternalSemanticAttributes.IS_REMOTE_PARENT;
55
import static io.sentry.opentelemetry.OtelInternalSpanDetectionUtil.isSentryRequest;
6+
import static io.sentry.opentelemetry.OtelSpanUtils.maybeTransferOtelAttribute;
67

78
import io.opentelemetry.api.common.Attributes;
89
import io.opentelemetry.api.trace.StatusCode;
@@ -12,6 +13,7 @@
1213
import io.opentelemetry.sdk.trace.export.SpanExporter;
1314
import io.opentelemetry.semconv.HttpAttributes;
1415
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
16+
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
1517
import io.sentry.Baggage;
1618
import io.sentry.DateUtils;
1719
import io.sentry.DefaultSpanFactory;
@@ -340,6 +342,9 @@ private void transferSpanDetails(
340342
setOtelSpanKind(span, sentryTransaction);
341343
transferSpanDetails(sentrySpanMaybe, sentryTransaction);
342344

345+
maybeTransferOtelAttribute(span, sentryTransaction, ThreadIncubatingAttributes.THREAD_ID);
346+
maybeTransferOtelAttribute(span, sentryTransaction, ThreadIncubatingAttributes.THREAD_NAME);
347+
343348
scopesToUse.configureScope(
344349
ScopeType.CURRENT,
345350
scope -> attributesExtractor.extract(span, scope, scopesToUse.getOptions()));

0 commit comments

Comments
 (0)