@@ -1111,7 +1111,7 @@ public void testHttpTracingEnabled_JsonResponseException_SetsAttributes() throws
11111111 "Invalid request" , rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .STATUS_MESSAGE ));
11121112 assertNull (rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .EXCEPTION_TYPE ));
11131113 }
1114-
1114+
11151115 @ Test
11161116 public void testGetUriTemplateValueTelemetry () throws Exception {
11171117 setMockResponse (
@@ -1145,37 +1145,38 @@ public void testGetUriTemplateValueTelemetry() throws Exception {
11451145 public void testResendCountOnRetry () throws Exception {
11461146 // Manually set attempt count to simulate being inside a retry loop
11471147 com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (2 );
1148+ try {
1149+ setMockResponse (
1150+ "{\" kind\" :\" bigquery#dataset\" ,\" id\" :\" "
1151+ + PROJECT_ID
1152+ + ":"
1153+ + DATASET_ID
1154+ + "\" ,\" datasetReference\" :{\" projectId\" :\" "
1155+ + PROJECT_ID
1156+ + "\" ,\" datasetId\" :\" "
1157+ + DATASET_ID
1158+ + "\" }}" );
11481159
1149- setMockResponse (
1150- "{\" kind\" :\" bigquery#dataset\" ,\" id\" :\" "
1151- + PROJECT_ID
1152- + ":"
1153- + DATASET_ID
1154- + "\" ,\" datasetReference\" :{\" projectId\" :\" "
1155- + PROJECT_ID
1156- + "\" ,\" datasetId\" :\" "
1157- + DATASET_ID
1158- + "\" }}" );
1159-
1160- rpc .getDatasetSkipExceptionTranslation (PROJECT_ID , DATASET_ID , new HashMap <>());
1161-
1162- List <io .opentelemetry .sdk .trace .data .SpanData > spans = spanExporter .getFinishedSpanItems ();
1163- assertThat (spans ).isNotEmpty ();
1164- io .opentelemetry .sdk .trace .data .SpanData rpcSpan =
1165- spans .stream ()
1166- .filter (s -> s .getName ().equals ("com.google.cloud.bigquery.BigQueryRpc.getDataset" ))
1167- .findFirst ()
1168- .orElse (null );
1169- assertNotNull (rpcSpan );
1170- assertEquals (
1171- 2L ,
1172- rpcSpan
1173- .getAttributes ()
1174- .get (
1175- com .google .cloud .bigquery .telemetry .HttpTracingRequestInitializer
1176- .HTTP_REQUEST_RESEND_COUNT ));
1160+ rpc .getDatasetSkipExceptionTranslation (PROJECT_ID , DATASET_ID , new HashMap <>());
11771161
1178- com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (0 );
1162+ List <io .opentelemetry .sdk .trace .data .SpanData > spans = spanExporter .getFinishedSpanItems ();
1163+ assertThat (spans ).isNotEmpty ();
1164+ io .opentelemetry .sdk .trace .data .SpanData rpcSpan =
1165+ spans .stream ()
1166+ .filter (s -> s .getName ().equals ("com.google.cloud.bigquery.BigQueryRpc.getDataset" ))
1167+ .findFirst ()
1168+ .orElse (null );
1169+ assertNotNull (rpcSpan );
1170+ assertEquals (
1171+ 2L ,
1172+ rpcSpan
1173+ .getAttributes ()
1174+ .get (
1175+ com .google .cloud .bigquery .telemetry .HttpTracingRequestInitializer
1176+ .HTTP_REQUEST_RESEND_COUNT ));
1177+ } finally {
1178+ com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (0 );
1179+ }
11791180 }
11801181 }
11811182
@@ -1285,36 +1286,37 @@ public void testHttpTracingDisabled_GoogleJsonResponseException_DoesNotSetAttrib
12851286 public void testResendCountNotSetWhenDisabled () throws Exception {
12861287 // Manually set attempt count to simulate being inside a retry loop
12871288 com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (2 );
1289+ try {
1290+ setMockResponse (
1291+ "{\" kind\" :\" bigquery#dataset\" ,\" id\" :\" "
1292+ + PROJECT_ID
1293+ + ":"
1294+ + DATASET_ID
1295+ + "\" ,\" datasetReference\" :{\" projectId\" :\" "
1296+ + PROJECT_ID
1297+ + "\" ,\" datasetId\" :\" "
1298+ + DATASET_ID
1299+ + "\" }}" );
12881300
1289- setMockResponse (
1290- "{\" kind\" :\" bigquery#dataset\" ,\" id\" :\" "
1291- + PROJECT_ID
1292- + ":"
1293- + DATASET_ID
1294- + "\" ,\" datasetReference\" :{\" projectId\" :\" "
1295- + PROJECT_ID
1296- + "\" ,\" datasetId\" :\" "
1297- + DATASET_ID
1298- + "\" }}" );
1299-
1300- rpc .getDatasetSkipExceptionTranslation (PROJECT_ID , DATASET_ID , new HashMap <>());
1301-
1302- List <io .opentelemetry .sdk .trace .data .SpanData > spans = spanExporter .getFinishedSpanItems ();
1303- assertThat (spans ).isNotEmpty ();
1304- io .opentelemetry .sdk .trace .data .SpanData rpcSpan =
1305- spans .stream ()
1306- .filter (s -> s .getName ().equals ("com.google.cloud.bigquery.BigQueryRpc.getDataset" ))
1307- .findFirst ()
1308- .orElse (null );
1309- assertNotNull (rpcSpan );
1310- assertNull (
1311- rpcSpan
1312- .getAttributes ()
1313- .get (
1314- com .google .cloud .bigquery .telemetry .HttpTracingRequestInitializer
1315- .HTTP_REQUEST_RESEND_COUNT ));
1301+ rpc .getDatasetSkipExceptionTranslation (PROJECT_ID , DATASET_ID , new HashMap <>());
13161302
1317- com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (0 );
1303+ List <io .opentelemetry .sdk .trace .data .SpanData > spans = spanExporter .getFinishedSpanItems ();
1304+ assertThat (spans ).isNotEmpty ();
1305+ io .opentelemetry .sdk .trace .data .SpanData rpcSpan =
1306+ spans .stream ()
1307+ .filter (s -> s .getName ().equals ("com.google.cloud.bigquery.BigQueryRpc.getDataset" ))
1308+ .findFirst ()
1309+ .orElse (null );
1310+ assertNotNull (rpcSpan );
1311+ assertNull (
1312+ rpcSpan
1313+ .getAttributes ()
1314+ .get (
1315+ com .google .cloud .bigquery .telemetry .HttpTracingRequestInitializer
1316+ .HTTP_REQUEST_RESEND_COUNT ));
1317+ } finally {
1318+ com .google .cloud .bigquery .BigQueryRetryAlgorithm .setCurrentAttempt (0 );
1319+ }
13181320 }
13191321 }
13201322
0 commit comments