@@ -734,7 +734,7 @@ public void testTransactionRunnerWithRetryOnBeginTransaction() {
734
734
assertTrue (
735
735
actualSpanNames ,
736
736
finishedSpanNames .contains ("CloudSpannerOperation.BatchCreateSessionsRequest" ));
737
-
737
+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute ( finishedSpans );
738
738
assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.BatchCreateSessions" ));
739
739
assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.BeginTransaction" ));
740
740
assertTrue (actualSpanNames , finishedSpanNames .contains ("Spanner.Commit" ));
@@ -750,6 +750,14 @@ public void testTransactionRunnerWithRetryOnBeginTransaction() {
750
750
.anyMatch (event -> event .getName ().equals ("Starting RPC retry 1" )));
751
751
}
752
752
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
+
753
761
@ Test
754
762
public void testSingleUseRetryOnExecuteStreamingSql () {
755
763
// First get the client to ensure that the BatchCreateSessions request has been executed.
@@ -798,6 +806,7 @@ public void testSingleUseRetryOnExecuteStreamingSql() {
798
806
executeStreamingQuery .toString (),
799
807
executeStreamingQuery .getEvents ().stream ()
800
808
.anyMatch (event -> event .getName ().contains ("Stream broken. Safe to retry" )));
809
+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute (finishedSpans );
801
810
}
802
811
803
812
@ Test
@@ -845,6 +854,7 @@ public void testRetryOnExecuteSql() {
845
854
executeSqlSpan .toString (),
846
855
executeSqlSpan .getEvents ().stream ()
847
856
.anyMatch (event -> event .getName ().equals ("Starting RPC retry 1" )));
857
+ verifyAtLeast1SpanHasXGoogSpannerRequestIdAttribute (finishedSpans );
848
858
}
849
859
850
860
@ Test
0 commit comments