@@ -150,17 +150,24 @@ private void verifySpan(
150150 assertThat (spans ).isNotEmpty ();
151151 SpanData rpcSpan =
152152 spans .stream ().filter (span -> span .getName ().equals (spanName )).findFirst ().orElse (null );
153- assertNotNull (rpcSpan );
154- assertEquals (service , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.service" )));
155- assertEquals (method , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.method" )));
156- assertEquals ("http" , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.system" )));
153+
154+ verifySpanProductionAttributes (service , method , attributes , rpcSpan );
155+
157156 assertNotNull (
158- rpcSpan .getAttributes ().get (BigQueryTelemetryTracer . URL_TEMPLATE ),
157+ rpcSpan .getAttributes ().get (AttributeKey . stringKey ( "url.template" ) ),
159158 "url.template attribute should be set" );
160159
161160 assertEquals (
162161 gcpResourceDestinationId ,
163162 rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .GCP_RESOURCE_DESTINATION_ID ));
163+ }
164+
165+ private void verifySpanProductionAttributes (
166+ String service , String method , Map <String , String > attributes , SpanData rpcSpan ) {
167+ assertNotNull (rpcSpan );
168+ assertEquals (service , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.service" )));
169+ assertEquals (method , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.method" )));
170+ assertEquals ("http" , rpcSpan .getAttributes ().get (AttributeKey .stringKey ("bq.rpc.system" )));
164171
165172 if (attributes != null ) {
166173 for (Map .Entry <String , String > entry : attributes .entrySet ()) {
@@ -1162,12 +1169,6 @@ public void testHttpTracingDisabledDoesNotAddAdditionalAttributes() throws Excep
11621169 rpc .getDatasetSkipExceptionTranslation (PROJECT_ID , DATASET_ID , new HashMap <>());
11631170
11641171 verifyRequest ("GET" , "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID );
1165- verifySpan (
1166- "com.google.cloud.bigquery.BigQueryRpc.getDataset" ,
1167- "DatasetService" ,
1168- "GetDataset" ,
1169- RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID ,
1170- Collections .singletonMap ("bq.rpc.response.dataset.id" , PROJECT_ID + ":" + DATASET_ID ));
11711172
11721173 List <SpanData > spans = spanExporter .getFinishedSpanItems ();
11731174 assertThat (spans ).isNotEmpty ();
@@ -1178,8 +1179,19 @@ public void testHttpTracingDisabledDoesNotAddAdditionalAttributes() throws Excep
11781179 .findFirst ()
11791180 .orElse (null );
11801181 assertNotNull (rpcSpan );
1182+ verifySpanProductionAttributes (
1183+ "DatasetService" ,
1184+ "GetDataset" ,
1185+ Collections .singletonMap ("bq.rpc.response.dataset.id" , PROJECT_ID + ":" + DATASET_ID ),
1186+ rpcSpan );
1187+
11811188 assertNull (rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .RPC_SYSTEM_NAME ));
11821189 assertNull (rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .GCP_CLIENT_SERVICE ));
1190+ assertNull (
1191+ rpcSpan .getAttributes ().get (AttributeKey .stringKey ("url.template" )),
1192+ "url.template attribute should not be set" );
1193+
1194+ assertNull (rpcSpan .getAttributes ().get (BigQueryTelemetryTracer .GCP_RESOURCE_DESTINATION_ID ));
11831195 }
11841196
11851197 @ Test
0 commit comments