@@ -24,6 +24,8 @@ import java.util.concurrent.atomic.AtomicInteger
2424import java.util.zip.ZipInputStream
2525import java.util.zip.ZipOutputStream
2626
27+ import static datadog.trace.api.sampling.PrioritySampling.UNSET
28+ import static datadog.trace.api.sampling.PrioritySampling.USER_KEEP
2729import static datadog.trace.core.PendingTraceBuffer.BUFFER_SIZE
2830import static java.nio.charset.StandardCharsets.UTF_8
2931
@@ -147,7 +149,7 @@ class PendingTraceBufferTest extends DDSpecification {
147149
148150 def " priority sampling is always sent" () {
149151 setup :
150- def parent = addContinuation(newSpanOf(factory. create(DDTraceId . ONE ), PrioritySampling . USER_KEEP ))
152+ def parent = addContinuation(newSpanOf(factory. create(DDTraceId . ONE ), USER_KEEP , 0 ))
151153 def metadataChecker = new SamplingPriorityMetadataChecker ()
152154
153155 when : " Fill the buffer - Only children - Priority taken from root"
@@ -452,24 +454,12 @@ class PendingTraceBufferTest extends DDSpecification {
452454 TracerFlare . addReporter {} // exercises default methods
453455 def dumpReporter = Mock (PendingTraceBuffer.TracerDump )
454456 TracerFlare . addReporter(dumpReporter)
455- def pendingTrace = factory. create(DDTraceId . ONE )
456- def parent = newSpanOf(pendingTrace )
457+ def trace = factory. create(DDTraceId . ONE )
458+ def parent = newSpanOf(trace, UNSET , System . currentTimeMillis() * 1000 )
457459 def child = newSpanOf(parent)
458460
459461 when :
460462 parent. finish()
461-
462- then :
463- pendingTrace. size() == 1
464- pendingTrace. pendingReferenceCount == 1
465- 1 * bufferSpy. enqueue(pendingTrace)
466- _ * bufferSpy. longRunningSpansEnabled()
467- _ * tracer. getPartialFlushMinSpans() >> 10
468- 1 * tracer. getTimeWithNanoTicks(_)
469- 1 * tracer. onRootSpanPublished(parent)
470- 0 * _
471-
472- when :
473463 buffer. start()
474464 def entries = buildAndExtractZip()
475465
@@ -478,7 +468,14 @@ class PendingTraceBufferTest extends DDSpecification {
478468 1 * dumpReporter. addReportToFlare(_)
479469 1 * dumpReporter. cleanupAfterFlare()
480470 entries. size() == 1
481- entries[" trace_dump.txt" ] == " example text"
471+ (entries[" trace_dump.txt" ] as String ). startsWith(" DDSpan [ t_id=1, s_id=1, p_id=0 ]" ) // TODO
472+
473+ then :
474+ child. finish()
475+
476+ then :
477+ trace. size() == 0
478+ trace. pendingReferenceCount == 0
482479 }
483480
484481
@@ -490,10 +487,10 @@ class PendingTraceBufferTest extends DDSpecification {
490487 }
491488
492489 static DDSpan newSpanOf (PendingTrace trace ) {
493- return newSpanOf(trace, PrioritySampling . UNSET )
490+ return newSpanOf(trace, UNSET , 0 )
494491 }
495492
496- static DDSpan newSpanOf (PendingTrace trace , int samplingPriority ) {
493+ static DDSpan newSpanOf (PendingTrace trace , int samplingPriority , long timestampMicro ) {
497494 def context = new DDSpanContext (
498495 trace. traceId,
499496 1 ,
@@ -514,7 +511,7 @@ class PendingTraceBufferTest extends DDSpecification {
514511 NoopPathwayContext . INSTANCE ,
515512 false ,
516513 PropagationTags . factory(). empty())
517- return DDSpan . create(" test" , 0 , context, null )
514+ return DDSpan . create(" test" , timestampMicro , context, null )
518515 }
519516
520517 static DDSpan newSpanOf (DDSpan parent ) {
@@ -527,7 +524,7 @@ class PendingTraceBufferTest extends DDSpecification {
527524 " fakeService" ,
528525 " fakeOperation" ,
529526 " fakeResource" ,
530- PrioritySampling . UNSET ,
527+ UNSET ,
531528 null ,
532529 Collections . emptyMap(),
533530 false ,
0 commit comments