Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

- Removed SentryExecutorService limit for delayed scheduled tasks ([#4846](https://github.com/getsentry/sentry-java/pull/4846))
- Fix visual artifacts for the Canvas strategy on some devices ([#4861](https://github.com/getsentry/sentry-java/pull/4861))
- Copy active span on scope clone ([#4878](https://github.com/getsentry/sentry-java/pull/4878))

### Improvements

Expand Down
1 change: 1 addition & 0 deletions sentry/src/main/java/io/sentry/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public Scope(final @NotNull SentryOptions options) {
private Scope(final @NotNull Scope scope) {
this.transaction = scope.transaction;
this.transactionName = scope.transactionName;
this.activeSpan = scope.activeSpan;
this.session = scope.session;
this.options = scope.options;
this.level = scope.level;
Expand Down
16 changes: 16 additions & 0 deletions sentry/src/test/java/io/sentry/ScopeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNotSame
import kotlin.test.assertNull
import kotlin.test.assertSame
import kotlin.test.assertTrue
import org.junit.Assert.assertArrayEquals
import org.mockito.kotlin.any
Expand Down Expand Up @@ -155,6 +156,21 @@ class ScopeTest {
assertEquals(attachment.contentType, actual.contentType)
}

@Test
fun `copying scope copies active span`() {
val scope = Scope(SentryOptions())

val transaction =
SentryTracer(TransactionContext("transaction-name", "op"), NoOpScopes.getInstance())
val span = transaction.startChild("child1")

scope.setActiveSpan(span)

val clone = scope.clone()

assertSame(span, clone.span)
}

@Test
fun `copying scope and changing the original values wont change the clone values`() {
val scope = Scope(SentryOptions())
Expand Down
Loading