@@ -734,7 +734,7 @@ public void testTransactionRunnerWithRetryOnBeginTransaction() {
734734 assertTrue (
735735 actualSpanNames ,
736736 finishedSpanNames .contains ("CloudSpannerOperation.BatchCreateSessionsRequest" ));
737-
737+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute ( finishedSpans );
738738 assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.BatchCreateSessions" ));
739739 assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.BeginTransaction" ));
740740 assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.Commit" ));
@@ -750,6 +750,14 @@ public void testTransactionRunnerWithRetryOnBeginTransaction() {
750750 .anyMatch (event -> event .getName ().equals ("Starting RPC retry 1" )));
751751 }
752752
753+ private void verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute (List <SpanData > finishedSpans ) {
754+ AttributeKey <String > attributeKey = AttributeKey .stringKey ("x_goog_spanner_request_id" );
755+ SpanData matchingSpan = finishedSpans .stream ()
756+ .filter (span -> !span .getAttributes ().get (attributeKey ).isEmpty ())
757+ .findAny ()
758+ .orElseThrow (IllegalStateException ::new );
759+ }
760+
753761 @ Test
754762 public void testSingleUseRetryOnExecuteStreamingSql () {
755763 // First get the client to ensure that the BatchCreateSessions request has been executed.
@@ -798,6 +806,7 @@ public void testSingleUseRetryOnExecuteStreamingSql() {
798806 executeStreamingQuery .toString (),
799807 executeStreamingQuery .getEvents ().stream ()
800808 .anyMatch (event -> event .getName ().contains ("Stream broken. Safe to retry" )));
809+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute (finishedSpans );
801810 }
802811
803812 @ Test
@@ -845,6 +854,7 @@ public void testRetryOnExecuteSql() {
845854 executeSqlSpan .toString (),
846855 executeSqlSpan .getEvents ().stream ()
847856 .anyMatch (event -> event .getName ().equals ("Starting RPC retry 1" )));
857+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute (finishedSpans );
848858 }
849859
850860 @ Test
0 commit comments