Skip to content

Commit 004741c

Browse files
adinauerclaude
andcommitted
ref(core): Remove force new trace transaction flag
Use parent span presence as the session trace lifecycle opt-out instead of a separate TransactionContext flag. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cc97e32 commit 004741c

4 files changed

Lines changed: 2 additions & 42 deletions

File tree

sentry/api/sentry.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,9 +4593,7 @@ public final class io/sentry/TransactionContext : io/sentry/SpanContext {
45934593
public fun getParentSamplingDecision ()Lio/sentry/TracesSamplingDecision;
45944594
public fun getTransactionNameSource ()Lio/sentry/protocol/TransactionNameSource;
45954595
public fun isForNextAppStart ()Z
4596-
public fun isForceNewTrace ()Z
45974596
public fun setForNextAppStart (Z)V
4598-
public fun setForceNewTrace (Z)V
45994597
public fun setName (Ljava/lang/String;)V
46004598
public fun setParentSampled (Ljava/lang/Boolean;)V
46014599
public fun setParentSampled (Ljava/lang/Boolean;Ljava/lang/Boolean;)V

sentry/src/main/java/io/sentry/Scopes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,7 @@ && getOptions().getProfileLifecycle() == ProfileLifecycle.TRACE
10271027
final @NotNull PropagationContext propagationContext =
10281028
getCombinedScopeView().getPropagationContext();
10291029
if (getOptions().isEnableSessionTraceLifecycle()
1030-
&& transactionContext.getParentSpanId() == null
1031-
&& !transactionContext.isForceNewTrace()) {
1030+
&& transactionContext.getParentSpanId() == null) {
10321031
return TransactionContext.fromPropagationContextAsRoot(
10331032
propagationContext, transactionContext);
10341033
}

sentry/src/main/java/io/sentry/TransactionContext.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public final class TransactionContext extends SpanContext {
1717
private @NotNull TransactionNameSource transactionNameSource;
1818
private @Nullable TracesSamplingDecision parentSamplingDecision;
1919
private boolean isForNextAppStart = false;
20-
private boolean forceNewTrace = false;
2120

2221
@ApiStatus.Internal
2322
public static TransactionContext fromPropagationContext(
@@ -57,7 +56,6 @@ public static TransactionContext fromPropagationContext(
5756
sessionContext.transactionNameSource = transactionContext.transactionNameSource;
5857
sessionContext.parentSamplingDecision = transactionContext.parentSamplingDecision;
5958
sessionContext.isForNextAppStart = transactionContext.isForNextAppStart;
60-
sessionContext.forceNewTrace = transactionContext.forceNewTrace;
6159
return sessionContext;
6260
}
6361

@@ -169,28 +167,6 @@ public void setTransactionNameSource(final @NotNull TransactionNameSource transa
169167
this.transactionNameSource = transactionNameSource;
170168
}
171169

172-
/**
173-
* Forces this transaction to start a new trace when session trace lifecycle is enabled.
174-
* Explicitly continued traces with a parent span are still preserved.
175-
*
176-
* @return true if this transaction should not reuse the session propagation context.
177-
*/
178-
@ApiStatus.Experimental
179-
public boolean isForceNewTrace() {
180-
return forceNewTrace;
181-
}
182-
183-
/**
184-
* Forces this transaction to start a new trace when session trace lifecycle is enabled.
185-
* Explicitly continued traces with a parent span are still preserved.
186-
*
187-
* @param forceNewTrace true to keep this transaction on a new trace.
188-
*/
189-
@ApiStatus.Experimental
190-
public void setForceNewTrace(final boolean forceNewTrace) {
191-
this.forceNewTrace = forceNewTrace;
192-
}
193-
194170
@ApiStatus.Internal
195171
public void setForNextAppStart(final boolean forNextAppStart) {
196172
isForNextAppStart = forNextAppStart;

sentry/src/test/java/io/sentry/ScopesTest.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,24 +1837,11 @@ class ScopesTest {
18371837
}
18381838

18391839
@Test
1840-
fun `when session trace lifecycle is enabled, forceNewTrace keeps transaction trace`() {
1841-
val scopes = generateScopes { it.isEnableSessionTraceLifecycle = true }
1842-
val context = TransactionContext("name", "op")
1843-
context.setForceNewTrace(true)
1844-
1845-
val transaction = scopes.startTransaction(context)
1846-
1847-
assertTrue(transaction is SentryTracer)
1848-
assertEquals(context.traceId, transaction.root.spanContext.traceId)
1849-
}
1850-
1851-
@Test
1852-
fun `forceNewTrace does not override continued trace with parent span`() {
1840+
fun `continued trace with parent span is not remapped to session trace`() {
18531841
val scopes = generateScopes { it.isEnableSessionTraceLifecycle = true }
18541842
val traceId = "75302ac48a024bde9a3b3734a82e36c8"
18551843
val parentSpanId = "1000000000000000"
18561844
val context = scopes.continueTrace("$traceId-$parentSpanId-1", emptyList())!!
1857-
context.setForceNewTrace(true)
18581845

18591846
val transaction = scopes.startTransaction(context)
18601847

0 commit comments

Comments
 (0)