@@ -177,64 +177,126 @@ void shouldHandleFailureInKafkaListener() {
177177 satisfies (longKey ("kafka.record.queue_time_ms" ), AbstractLongAssert ::isNotNegative ));
178178
179179 AtomicReference <SpanData > producer = new AtomicReference <>();
180- testing .waitAndAssertSortedTraces (
181- orderByRootSpanKind (SpanKind .INTERNAL , SpanKind .CONSUMER ),
182- trace -> {
183- trace .hasSpansSatisfyingExactly (
184- span -> span .hasName ("producer" ),
185- span ->
186- span .hasName ("testSingleTopic publish" )
187- .hasKind (SpanKind .PRODUCER )
188- .hasParent (trace .getSpan (0 ))
189- .hasAttributesSatisfyingExactly (
190- equalTo (MESSAGING_SYSTEM , "kafka" ),
191- equalTo (MESSAGING_DESTINATION_NAME , "testSingleTopic" ),
192- equalTo (MESSAGING_OPERATION , "publish" ),
193- satisfies (
194- MESSAGING_DESTINATION_PARTITION_ID , AbstractStringAssert ::isNotEmpty ),
195- satisfies (
196- MESSAGING_KAFKA_MESSAGE_OFFSET , AbstractLongAssert ::isNotNegative ),
197- equalTo (MESSAGING_KAFKA_MESSAGE_KEY , "10" ),
198- satisfies (
199- MESSAGING_CLIENT_ID ,
200- stringAssert -> stringAssert .startsWith ("producer" ))));
201-
202- producer .set (trace .getSpan (1 ));
203- },
204- trace ->
205- trace .hasSpansSatisfyingExactly (
206- receiveSpanAssert ,
207- span ->
208- span .hasName ("testSingleTopic process" )
209- .hasKind (SpanKind .CONSUMER )
210- .hasParent (trace .getSpan (0 ))
211- .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
212- .hasStatus (StatusData .error ())
213- .hasException (new IllegalArgumentException ("boom" ))
214- .hasAttributesSatisfyingExactly (processAttributes ),
215- span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))),
216- trace ->
180+ // trace structure differs in latest dep tests because CommonErrorHandler is only set for latest
181+ // dep tests
182+ if (Boolean .getBoolean ("testLatestDeps" )) {
183+ testing .waitAndAssertSortedTraces (
184+ orderByRootSpanKind (SpanKind .INTERNAL , SpanKind .CONSUMER ),
185+ trace -> {
217186 trace .hasSpansSatisfyingExactly (
218- receiveSpanAssert ,
187+ span -> span . hasName ( "producer" ) ,
219188 span ->
220- span .hasName ("testSingleTopic process " )
221- .hasKind (SpanKind .CONSUMER )
189+ span .hasName ("testSingleTopic publish " )
190+ .hasKind (SpanKind .PRODUCER )
222191 .hasParent (trace .getSpan (0 ))
223- .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
224- .hasStatus (StatusData .error ())
225- .hasException (new IllegalArgumentException ("boom" ))
226- .hasAttributesSatisfyingExactly (processAttributes ),
227- span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))),
228- trace ->
192+ .hasAttributesSatisfyingExactly (
193+ equalTo (MESSAGING_SYSTEM , "kafka" ),
194+ equalTo (MESSAGING_DESTINATION_NAME , "testSingleTopic" ),
195+ equalTo (MESSAGING_OPERATION , "publish" ),
196+ satisfies (
197+ MESSAGING_DESTINATION_PARTITION_ID ,
198+ AbstractStringAssert ::isNotEmpty ),
199+ satisfies (
200+ MESSAGING_KAFKA_MESSAGE_OFFSET , AbstractLongAssert ::isNotNegative ),
201+ equalTo (MESSAGING_KAFKA_MESSAGE_KEY , "10" ),
202+ satisfies (
203+ MESSAGING_CLIENT_ID ,
204+ stringAssert -> stringAssert .startsWith ("producer" ))));
205+
206+ producer .set (trace .getSpan (1 ));
207+ },
208+ trace ->
209+ trace .hasSpansSatisfyingExactly (
210+ receiveSpanAssert ,
211+ span ->
212+ span .hasName ("testSingleTopic process" )
213+ .hasKind (SpanKind .CONSUMER )
214+ .hasParent (trace .getSpan (0 ))
215+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
216+ .hasStatus (StatusData .error ())
217+ .hasException (new IllegalArgumentException ("boom" ))
218+ .hasAttributesSatisfyingExactly (processAttributes ),
219+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 )),
220+ span -> span .hasName ("handle exception" ).hasParent (trace .getSpan (1 )),
221+ span ->
222+ span .hasName ("testSingleTopic process" )
223+ .hasKind (SpanKind .CONSUMER )
224+ .hasParent (trace .getSpan (0 ))
225+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
226+ .hasStatus (StatusData .error ())
227+ .hasException (new IllegalArgumentException ("boom" ))
228+ .hasAttributesSatisfyingExactly (processAttributes ),
229+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (4 )),
230+ span -> span .hasName ("handle exception" ).hasParent (trace .getSpan (4 )),
231+ span ->
232+ span .hasName ("testSingleTopic process" )
233+ .hasKind (SpanKind .CONSUMER )
234+ .hasParent (trace .getSpan (0 ))
235+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
236+ .hasAttributesSatisfyingExactly (processAttributes ),
237+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (7 ))));
238+
239+ } else {
240+ testing .waitAndAssertSortedTraces (
241+ orderByRootSpanKind (SpanKind .INTERNAL , SpanKind .CONSUMER ),
242+ trace -> {
229243 trace .hasSpansSatisfyingExactly (
230- receiveSpanAssert ,
244+ span -> span . hasName ( "producer" ) ,
231245 span ->
232- span .hasName ("testSingleTopic process " )
233- .hasKind (SpanKind .CONSUMER )
246+ span .hasName ("testSingleTopic publish " )
247+ .hasKind (SpanKind .PRODUCER )
234248 .hasParent (trace .getSpan (0 ))
235- .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
236- .hasAttributesSatisfyingExactly (processAttributes ),
237- span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))));
249+ .hasAttributesSatisfyingExactly (
250+ equalTo (MESSAGING_SYSTEM , "kafka" ),
251+ equalTo (MESSAGING_DESTINATION_NAME , "testSingleTopic" ),
252+ equalTo (MESSAGING_OPERATION , "publish" ),
253+ satisfies (
254+ MESSAGING_DESTINATION_PARTITION_ID ,
255+ AbstractStringAssert ::isNotEmpty ),
256+ satisfies (
257+ MESSAGING_KAFKA_MESSAGE_OFFSET , AbstractLongAssert ::isNotNegative ),
258+ equalTo (MESSAGING_KAFKA_MESSAGE_KEY , "10" ),
259+ satisfies (
260+ MESSAGING_CLIENT_ID ,
261+ stringAssert -> stringAssert .startsWith ("producer" ))));
262+
263+ producer .set (trace .getSpan (1 ));
264+ },
265+ trace ->
266+ trace .hasSpansSatisfyingExactly (
267+ receiveSpanAssert ,
268+ span ->
269+ span .hasName ("testSingleTopic process" )
270+ .hasKind (SpanKind .CONSUMER )
271+ .hasParent (trace .getSpan (0 ))
272+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
273+ .hasStatus (StatusData .error ())
274+ .hasException (new IllegalArgumentException ("boom" ))
275+ .hasAttributesSatisfyingExactly (processAttributes ),
276+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))),
277+ trace ->
278+ trace .hasSpansSatisfyingExactly (
279+ receiveSpanAssert ,
280+ span ->
281+ span .hasName ("testSingleTopic process" )
282+ .hasKind (SpanKind .CONSUMER )
283+ .hasParent (trace .getSpan (0 ))
284+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
285+ .hasStatus (StatusData .error ())
286+ .hasException (new IllegalArgumentException ("boom" ))
287+ .hasAttributesSatisfyingExactly (processAttributes ),
288+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))),
289+ trace ->
290+ trace .hasSpansSatisfyingExactly (
291+ receiveSpanAssert ,
292+ span ->
293+ span .hasName ("testSingleTopic process" )
294+ .hasKind (SpanKind .CONSUMER )
295+ .hasParent (trace .getSpan (0 ))
296+ .hasLinks (LinkData .create (producer .get ().getSpanContext ()))
297+ .hasAttributesSatisfyingExactly (processAttributes ),
298+ span -> span .hasName ("consumer" ).hasParent (trace .getSpan (1 ))));
299+ }
238300 }
239301
240302 @ Test
0 commit comments