Skip to content

Commit c6ed471

Browse files
committed
initial implementation of test
1 parent d2fc878 commit c6ed471

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

dd-trace-core/src/main/java/datadog/trace/core/PendingTraceBuffer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ private String getDumpText() {
384384
PendingTrace)); // Removing elements from the drain that are not instances of
385385
// PendingTrace
386386

387-
DelayingPendingTraceBuffer.DumpDrain.data.sort((TRACE_BY_START_TIME).reversed()); // Storing oldest traces first
387+
DelayingPendingTraceBuffer.DumpDrain.data.sort(
388+
(TRACE_BY_START_TIME).reversed()); // Storing oldest traces first
388389

389390
StringBuilder dumpText = new StringBuilder();
390391
for (Element e : DelayingPendingTraceBuffer.DumpDrain.data) {
@@ -395,7 +396,8 @@ private String getDumpText() {
395396
}
396397
}
397398
}
398-
DelayingPendingTraceBuffer.DumpDrain.data.clear(); // releasing memory used for ArrayList in drain
399+
DelayingPendingTraceBuffer.DumpDrain.data
400+
.clear(); // releasing memory used for ArrayList in drain
399401
return dumpText.toString();
400402
}
401403
}

dd-trace-core/src/test/groovy/datadog/trace/core/PendingTraceBufferTest.groovy

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class PendingTraceBufferTest extends DDSpecification {
449449

450450
def "testing tracer flare dump"() {
451451
setup:
452-
// Don't start the buffer thread
452+
buffer.start()
453453
TracerFlare.addReporter {} // exercises default methods
454454
def dumpReporter = Mock(PendingTraceBuffer.TracerDump)
455455
TracerFlare.addReporter(dumpReporter)
@@ -461,54 +461,10 @@ class PendingTraceBufferTest extends DDSpecification {
461461

462462
then:
463463
1 * dumpReporter.prepareForFlare()
464-
465-
then:
466464
1 * dumpReporter.addReportToFlare(_)
467-
468-
then:
469465
1 * dumpReporter.cleanupAfterFlare()
470-
471-
and:
472-
entries.size() == 2
466+
entries.size() == 1
473467
entries["trace_dump.txt"] == "example text"
474-
entries["flare_errors.txt"] =~
475-
/^(java.lang.IllegalStateException: (bin|txt) \(expected\)\n){2}$/
476-
// then:
477-
// 1 * tracer.captureTraceConfig() >> traceConfig
478-
// pendingTrace.rootSpanWritten
479-
// pendingTrace.isEnqueued == 0
480-
// buffer.queue.size() == 0
481-
// _ * bufferSpy.longRunningSpansEnabled()
482-
// 1 * tracer.writeTimer() >> Monitoring.DISABLED.newTimer("")
483-
// 1 * tracer.write({ it.size() == 1 })
484-
// 1 * tracer.getPartialFlushMinSpans() >> 10000
485-
// 1 * traceConfig.getServiceMapping() >> [:]
486-
// 2 * tracer.getTimeWithNanoTicks(_)
487-
// 1 * tracer.onRootSpanPublished(_)
488-
// 0 * _
489-
//
490-
// when: "fail to fill the buffer"
491-
// for (i in 1..buffer.queue.capacity()) {
492-
// addContinuation(newSpanOf(span)).finish()
493-
// }
494-
//
495-
// then:
496-
// pendingTrace.isEnqueued == 1
497-
// buffer.queue.size() == 1
498-
// buffer.queue.capacity() * bufferSpy.enqueue(_)
499-
// _ * bufferSpy.longRunningSpansEnabled()
500-
// _ * tracer.getPartialFlushMinSpans() >> 10000
501-
// _ * traceConfig.getServiceMapping() >> [:]
502-
// _ * tracer.getTimeWithNanoTicks(_)
503-
// 0 * _
504-
//
505-
// when: "process the buffer"
506-
// buffer.start()
507-
//
508-
// then:
509-
// new PollingConditions(timeout: 3, initialDelay: 0, delay: 0.5, factor: 1).eventually {
510-
// assert pendingTrace.isEnqueued == 0
511-
// }
512468
}
513469

514470

@@ -589,7 +545,7 @@ class PendingTraceBufferTest extends DDSpecification {
589545
def bytes = new ByteArrayOutputStream()
590546
bytes << zip
591547
entries.put(entry.name, entry.name.endsWith(".bin")
592-
? bytes.toByteArray() : new String(bytes.toByteArray(), UTF_8))
548+
? bytes.toByteArray() : new String(bytes.toByteArray(), UTF_8))
593549
}
594550

595551
return entries

0 commit comments

Comments
 (0)