File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
features/dd-sdk-android-trace-internal
main/java/com/datadog/trace/core
test/kotlin/com/datadog/trace/core Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -3004,7 +3004,6 @@ public class com/datadog/trace/core/PendingTrace : com/datadog/trace/bootstrap/i
3004
3004
public fun setSamplingPriorityIfNecessary ()V
3005
3005
public fun size ()I
3006
3006
public fun touch ()V
3007
- public fun unregisterSpan (Lcom/datadog/trace/core/DDSpan;)V
3008
3007
public fun write ()V
3009
3008
public fun writeOnBufferFull ()Z
3010
3009
}
Original file line number Diff line number Diff line change @@ -223,9 +223,8 @@ void registerSpan(final DDSpan span) {
223
223
}
224
224
}
225
225
226
- public void unregisterSpan (final DDSpan span ){
226
+ void unregisterSpan (final DDSpan span ){
227
227
PENDING_REFERENCE_COUNT .decrementAndGet (this );
228
- ROOT_SPAN .compareAndSet (this , span , null );
229
228
if (pendingTraceBuffer .longRunningSpansEnabled ()){
230
229
spans .remove (span );
231
230
}
Original file line number Diff line number Diff line change @@ -187,6 +187,37 @@ internal class PendingTraceTest : PendingTraceTestBase() {
187
187
assertThat(trace.spans).containsExactlyInAnyOrder(unfinishedSpan, unfinishedSpan2)
188
188
}
189
189
190
+ @Test
191
+ fun `do not drop root span when drop is called` () {
192
+ // Given
193
+ val tracer = mock<CoreTracer >()
194
+ val traceConfig = mock<CoreTracer .ConfigSnapshot >()
195
+ val buffer = mock<PendingTraceBuffer >()
196
+ val healthMetrics = mock<HealthMetrics >()
197
+ whenever(tracer.captureTraceConfig()).thenReturn(traceConfig)
198
+ whenever(traceConfig.serviceMapping).thenReturn(emptyMap())
199
+ val trace = createInstanceWithoutTypeCheck(
200
+ PendingTrace ::class .java,
201
+ tracer,
202
+ DDTraceId .from(0 ),
203
+ buffer,
204
+ mock<TimeSource >(),
205
+ mock<ConfigSnapshot >(),
206
+ false ,
207
+ healthMetrics
208
+ )
209
+ rootSpan = createSimpleSpan(trace)
210
+ trace.registerSpan(rootSpan)
211
+
212
+ // When
213
+ trace.unregisterSpan(rootSpan)
214
+
215
+ // Then
216
+ assertThat(trace.pendingReferenceCount).isEqualTo(0 )
217
+ assertThat(trace.spans).isEmpty()
218
+ assertThat(trace.rootSpan).isEqualTo(rootSpan)
219
+ }
220
+
190
221
private fun createSimpleSpan (trace : PendingTrace ): DDSpan {
191
222
return createSimpleSpanWithID(trace, 1 )
192
223
}
You can’t perform that action at this time.
0 commit comments