@@ -2,6 +2,8 @@ package datadog.trace.agent.test.asserts
22
33import static TraceAssert.assertTrace
44
5+ import datadog.trace.agent.tooling.muzzle.MuzzleCheck
6+ import datadog.trace.bootstrap.InstrumentationErrors
57import datadog.trace.common.writer.ListWriter
68import datadog.trace.core.DDSpan
79import groovy.transform.stc.ClosureParams
@@ -47,7 +49,15 @@ class ListWriterAssert {
4749 @ClosureParams (value = SimpleType , options = [' datadog.trace.agent.test.asserts.ListWriterAssert' ])
4850 @DelegatesTo (value = ListWriterAssert , strategy = Closure .DELEGATE_FIRST ) Closure spec ) {
4951 try {
50- writer. waitForTraces(expectedSize)
52+ // Fail fast if we see any muzzle errors or instrumentation errors
53+ for (int timeoutRemaining = ListWriter . WAIT_FOR_TRACES_TIMEOUT_SECONDS ; timeoutRemaining > 0 ; timeoutRemaining-- ) {
54+ if (writer. waitForTracesMax(expectedSize, 1 )) {
55+ break
56+ }
57+ assertNoErrors()
58+ }
59+ assertNoErrors() // even if we break immediately above, make sure we check for errors at least once
60+ writer. waitForTraces(expectedSize, 0 )
5161 def array = writer. toArray()
5262 assert array. length == expectedSize
5363 def traces = (Arrays . asList(array) as List<List<DDSpan > > )
@@ -91,6 +101,12 @@ class ListWriterAssert {
91101 }
92102 }
93103
104+ static void assertNoErrors () {
105+ assert InstrumentationErrors . getErrors(). size() == 0 : " Instrumentation errors were seen, failing fast"
106+ assert MuzzleCheck . getErrors(). size() == 0 : " Muzzle errors were seen, failing fast"
107+ // InstrumentationSpecification.{cleanup,cleanupAfterAgent} will provide details later
108+ }
109+
94110 void sortSpansByStart () {
95111 traces = traces. collect {
96112 return new ArrayList<DDSpan > (it). sort { a , b ->
0 commit comments