From a104971e54e9f4d8cc4c2cc22d9dde3b5467e9b9 Mon Sep 17 00:00:00 2001 From: ldetmer Date: Thu, 2 Apr 2026 11:15:12 -0400 Subject: [PATCH 1/4] chore(bigquery): remove dev gate flag for tracing telemetry --- .../bigquery/spi/v2/HttpBigQueryRpc.java | 38 +- .../bigquery/it/ITOpenTelemetryTest.java | 1 - .../bigquery/spi/v2/HttpBigQueryRpcTest.java | 1060 ++++++++--------- 3 files changed, 486 insertions(+), 613 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java index e789239b5589..587ad3fc3af7 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java @@ -88,8 +88,6 @@ public class HttpBigQueryRpc implements BigQueryRpc { public static final String DEFAULT_PROJECTION = "full"; private static final String BASE_RESUMABLE_URI = "upload/bigquery/v2/projects/"; - static final String HTTP_TRACING_DEV_GATE_PROPERTY = - "com.google.cloud.bigquery.http.tracing.dev.enabled"; static final String RESOURCE_PROJECT_PREFIX = "//bigquery.googleapis.com/projects/"; // see: // https://cloud.google.com/bigquery/loading-data-post-request#resume-upload @@ -121,8 +119,7 @@ public HttpBigQueryRpc(BigQueryOptions options) { this.urlDomain = new GenericUrl(options.getResolvedApiaryHost("bigquery")).getHost(); if (options.isOpenTelemetryTracingEnabled() - && options.getOpenTelemetryTracer() != null - && isHttpTracingEnabled()) { + && options.getOpenTelemetryTracer() != null) { initializer = new HttpTracingRequestInitializer(initializer, options.getOpenTelemetryTracer()); } @@ -2146,14 +2143,11 @@ private Span createRpcTracingSpan( .setSpanKind(SpanKind.CLIENT) .setAttribute("bq.rpc.service", service) .setAttribute("bq.rpc.method", method) - .setAttribute("bq.rpc.system", "http"); - if (isHttpTracingEnabled()) { - builder - .setAttribute( - BigQueryTelemetryTracer.GCP_RESOURCE_DESTINATION_ID, gcpResourceDestinationId) - .setAttribute(BigQueryTelemetryTracer.URL_TEMPLATE, urlTemplate) - .setAttribute(BigQueryTelemetryTracer.URL_DOMAIN, this.urlDomain); - } + .setAttribute("bq.rpc.system", "http") + .setAttribute( + BigQueryTelemetryTracer.GCP_RESOURCE_DESTINATION_ID, gcpResourceDestinationId) + .setAttribute(BigQueryTelemetryTracer.URL_TEMPLATE, urlTemplate) + .setAttribute(BigQueryTelemetryTracer.URL_DOMAIN, this.urlDomain); if (options != null) { builder.setAllAttributes(otelAttributesFromOptions(options)); @@ -2175,13 +2169,11 @@ private T executeWithSpan(Span span, SpanOperation operation) throws IOEx try (Scope scope = span.makeCurrent()) { return operation.execute(span); } catch (Exception e) { - if (isHttpTracingEnabled()) { - if (e instanceof GoogleJsonResponseException) { - BigQueryTelemetryTracer.addServerErrorResponseToSpan( - ((GoogleJsonResponseException) e), span); - } else { - BigQueryTelemetryTracer.addExceptionToSpan(e, span); - } + if (e instanceof GoogleJsonResponseException) { + BigQueryTelemetryTracer.addServerErrorResponseToSpan( + ((GoogleJsonResponseException) e), span); + } else { + BigQueryTelemetryTracer.addExceptionToSpan(e, span); } throw e; } finally { @@ -2203,12 +2195,4 @@ private static Attributes otelAttributesFromOptions(Map options) { return builder.build(); } - /** - * Temporary development gate for HttpTracingRequestInitializer rollout: must be explicitly - * enabled with the system property. tracking ticket for removal: - * https://github.com/googleapis/google-cloud-java/issues/12100 - */ - static boolean isHttpTracingEnabled() { - return Boolean.parseBoolean(System.getProperty(HTTP_TRACING_DEV_GATE_PROPERTY)); - } } diff --git a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITOpenTelemetryTest.java b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITOpenTelemetryTest.java index d42f193c56fd..bb6e4cdba0fa 100644 --- a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITOpenTelemetryTest.java +++ b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITOpenTelemetryTest.java @@ -54,7 +54,6 @@ public class ITOpenTelemetryTest { @BeforeAll public static void setUpClass() throws IOException { - System.setProperty("com.google.cloud.bigquery.http.tracing.dev.enabled", "true"); bigqueryHelper = RemoteBigQueryHelper.create(); } diff --git a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java index 7a98b3b9dd07..74d0371b10cc 100644 --- a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java +++ b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java @@ -67,9 +67,6 @@ import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; -// same thread execution temporarily required for using java system properties will get removed in -// issue https://github.com/googleapis/google-cloud-java/issues/12100 -@Execution(ExecutionMode.SAME_THREAD) public class HttpBigQueryRpcTest { private static final String PROJECT_ID = "test-project"; @@ -225,83 +222,82 @@ class TelemetryEnabled { @BeforeEach public void setUp() { setUpServer(); - System.setProperty("com.google.cloud.bigquery.http.tracing.dev.enabled", "true"); rpc = createRpc(true); } @Test public void testSpanEndOnError() { assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); // Verify that span was ended (collected) despite the error verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + null); } @Test public void testGetDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test public void testListDatasetsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#datasetList\",\"datasets\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#datasetList\",\"datasets\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listDatasetsSkipExceptionTranslation(PROJECT_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listDatasets", - "DatasetService", - "ListDatasets", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listDatasets", + "DatasetService", + "ListDatasets", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); Dataset dataset = new Dataset(); dataset.setDatasetReference( - new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); + new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); rpc.createSkipExceptionTranslation(dataset, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createDataset", - "DatasetService", - "InsertDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createDataset", + "DatasetService", + "InsertDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test @@ -313,99 +309,99 @@ public void testDeleteDatasetTelemetry() throws Exception { verifyRequest("DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteDataset", - "DatasetService", - "DeleteDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteDataset", + "DatasetService", + "DeleteDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + null); } @Test public void testPatchDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); Dataset dataset = new Dataset(); dataset.setDatasetReference( - new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); + new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); rpc.patchSkipExceptionTranslation(dataset, new HashMap<>()); verifyRequest("PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchDataset", - "DatasetService", - "PatchDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchDataset", + "DatasetService", + "PatchDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test public void testGetTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); rpc.getTableSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getTable", - "TableService", - "GetTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getTable", + "TableService", + "GetTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test public void testListTablesTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#tableList\",\"tables\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#tableList\",\"tables\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listTablesSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTables", - "TableService", - "ListTables", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listTables", + "TableService", + "ListTables", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); Table table = new Table(); table.setTableReference( - new TableReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setTableId(TABLE_ID)); + new TableReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setTableId(TABLE_ID)); rpc.createSkipExceptionTranslation(table, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createTable", - "TableService", - "InsertTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createTable", + "TableService", + "InsertTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test @@ -416,111 +412,111 @@ public void testDeleteTableTelemetry() throws Exception { rpc.deleteTableSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID); verifyRequest( - "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteTable", - "TableService", - "DeleteTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteTable", + "TableService", + "DeleteTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testPatchTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); Table table = new Table(); table.setTableReference( - new TableReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setTableId(TABLE_ID)); + new TableReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setTableId(TABLE_ID)); rpc.patchSkipExceptionTranslation(table, new HashMap<>()); verifyRequest( - "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchTable", - "TableService", - "PatchTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchTable", + "TableService", + "PatchTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test public void testGetModelTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"modelId\":\"" - + MODEL_ID - + "\"}}"); + "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"modelId\":\"" + + MODEL_ID + + "\"}}"); rpc.getModelSkipExceptionTranslation(PROJECT_ID, DATASET_ID, MODEL_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getModel", - "ModelService", - "GetModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getModel", + "ModelService", + "GetModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); } @Test public void testListModelsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#modelList\",\"models\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#modelList\",\"models\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listModelsSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listModels", - "ModelService", - "ListModels", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listModels", + "ModelService", + "ListModels", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testPatchModelTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"modelId\":\"" - + MODEL_ID - + "\"}}"); + "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"modelId\":\"" + + MODEL_ID + + "\"}}"); Model model = new Model(); model.setModelReference( - new ModelReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setModelId(MODEL_ID)); + new ModelReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setModelId(MODEL_ID)); rpc.patchSkipExceptionTranslation(model, new HashMap<>()); verifyRequest( - "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchModel", - "ModelService", - "PatchModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchModel", + "ModelService", + "PatchModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); } @Test @@ -531,90 +527,90 @@ public void testDeleteModelTelemetry() throws Exception { rpc.deleteModelSkipExceptionTranslation(PROJECT_ID, DATASET_ID, MODEL_ID); verifyRequest( - "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteModel", - "ModelService", - "DeleteModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteModel", + "ModelService", + "DeleteModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + null); } @Test public void testGetRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); rpc.getRoutineSkipExceptionTranslation(PROJECT_ID, DATASET_ID, ROUTINE_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getRoutine", - "RoutineService", - "GetRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getRoutine", + "RoutineService", + "GetRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test public void testListRoutinesTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routineList\",\"routines\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#routineList\",\"routines\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listRoutinesSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listRoutines", - "RoutineService", - "ListRoutines", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listRoutines", + "RoutineService", + "ListRoutines", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); Routine routine = new Routine(); routine.setRoutineReference( - new RoutineReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setRoutineId(ROUTINE_ID)); + new RoutineReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setRoutineId(ROUTINE_ID)); rpc.createSkipExceptionTranslation(routine, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createRoutine", - "RoutineService", - "InsertRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createRoutine", + "RoutineService", + "InsertRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test @@ -625,53 +621,53 @@ public void testDeleteRoutineTelemetry() throws Exception { rpc.deleteRoutineSkipExceptionTranslation(PROJECT_ID, DATASET_ID, ROUTINE_ID); verifyRequest( - "DELETE", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "DELETE", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteRoutine", - "RoutineService", - "DeleteRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteRoutine", + "RoutineService", + "DeleteRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + null); } @Test public void testUpdateRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); Routine routine = new Routine(); routine.setRoutineReference( - new RoutineReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setRoutineId(ROUTINE_ID)); + new RoutineReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setRoutineId(ROUTINE_ID)); rpc.updateSkipExceptionTranslation(routine, new HashMap<>()); verifyRequest( - "PUT", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "PUT", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.updateRoutine", - "RoutineService", - "UpdateRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.updateRoutine", + "RoutineService", + "UpdateRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test @@ -682,20 +678,20 @@ public void testInsertAllTelemetry() throws Exception { rpc.insertAllSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, request); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + "/insertAll"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + "/insertAll"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.insertAll", - "TableDataService", - "InsertAll", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.insertAll", + "TableDataService", + "InsertAll", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -705,14 +701,14 @@ public void testListTableDataTelemetry() throws Exception { rpc.listTableDataSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, new HashMap<>()); verifyRequest( - "GET", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); + "GET", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTableData", - "TableDataService", - "List", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.listTableData", + "TableDataService", + "List", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -720,27 +716,27 @@ public void testListTableDataWithRowLimitTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#tableDataList\",\"rows\":[]}"); rpc.listTableDataWithRowLimitSkipExceptionTranslation( - PROJECT_ID, DATASET_ID, TABLE_ID, 10, null); + PROJECT_ID, DATASET_ID, TABLE_ID, 10, null); verifyRequest( - "GET", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); + "GET", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTableDataWithRowLimit", - "TableDataService", - "List", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.listTableDataWithRowLimit", + "TableDataService", + "List", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testGetJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); rpc.getJobSkipExceptionTranslation(PROJECT_ID, JOB_ID, LOCATION, new HashMap<>()); @@ -749,21 +745,21 @@ public void testGetJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getJob", - "JobService", - "GetJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - attributes); + "com.google.cloud.bigquery.BigQueryRpc.getJob", + "JobService", + "GetJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + attributes); } @Test public void testGetQueryJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); rpc.getQueryJobSkipExceptionTranslation(PROJECT_ID, JOB_ID, LOCATION); @@ -772,37 +768,37 @@ public void testGetQueryJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryJob", - "JobService", - "GetJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - attributes); + "com.google.cloud.bigquery.BigQueryRpc.getQueryJob", + "JobService", + "GetJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + attributes); } @Test public void testListJobsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#jobList\",\"jobs\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#jobList\",\"jobs\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listJobsSkipExceptionTranslation(PROJECT_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/jobs"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listJobs", - "JobService", - "ListJobs", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listJobs", + "JobService", + "ListJobs", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); Job job = new Job(); job.setJobReference(new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID)); @@ -813,21 +809,21 @@ public void testCreateJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createJob", - "JobService", - "InsertJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - attributes); + "com.google.cloud.bigquery.BigQueryRpc.createJob", + "JobService", + "InsertJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + attributes); } @Test public void testCreateJobForQueryTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); Job job = new Job(); job.setJobReference(new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID)); @@ -838,11 +834,11 @@ public void testCreateJobForQueryTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createJobForQuery", - "JobService", - "InsertJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - attributes); + "com.google.cloud.bigquery.BigQueryRpc.createJobForQuery", + "JobService", + "InsertJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + attributes); } @Test @@ -853,11 +849,11 @@ public void testCancelJobTelemetry() throws Exception { verifyRequest("POST", "/projects/" + PROJECT_ID + "/jobs/" + JOB_ID + "/cancel"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.cancelJob", - "JobService", - "CancelJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.cancelJob", + "JobService", + "CancelJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -869,11 +865,11 @@ public void testDeleteJobTelemetry() throws Exception { verifyRequest("DELETE", "/projects/" + PROJECT_ID + "/jobs/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteJob", - "JobService", - "DeleteJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteJob", + "JobService", + "DeleteJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -884,11 +880,11 @@ public void testGetQueryResultsTelemetry() throws Exception { verifyRequest("GET", "/projects/" + PROJECT_ID + "/queries/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryResults", - "JobService", - "GetQueryResults", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getQueryResults", + "JobService", + "GetQueryResults", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -896,15 +892,15 @@ public void testGetQueryResultsWithRowLimitTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#getQueryResultsResponse\"}"); rpc.getQueryResultsWithRowLimitSkipExceptionTranslation( - PROJECT_ID, JOB_ID, LOCATION, 10, 1000L); + PROJECT_ID, JOB_ID, LOCATION, 10, 1000L); verifyRequest("GET", "/projects/" + PROJECT_ID + "/queries/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryResultsWithRowLimit", - "JobService", - "GetQueryResults", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getQueryResultsWithRowLimit", + "JobService", + "GetQueryResults", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -915,11 +911,11 @@ public void testQueryRpcTelemetry() throws Exception { verifyRequest("POST", "/projects/" + PROJECT_ID + "/queries"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.queryRpc", - "JobService", - "Query", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - null); + "com.google.cloud.bigquery.BigQueryRpc.queryRpc", + "JobService", + "Query", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + null); } @Test @@ -927,24 +923,24 @@ public void testGetIamPolicyTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#policy\"}"); rpc.getIamPolicySkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":getIamPolicy"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":getIamPolicy"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getIamPolicy", - "TableService", - "GetIamPolicy", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getIamPolicy", + "TableService", + "GetIamPolicy", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -952,25 +948,25 @@ public void testSetIamPolicyTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#policy\"}"); rpc.setIamPolicySkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - new Policy(), - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + new Policy(), + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":setIamPolicy"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":setIamPolicy"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.setIamPolicy", - "TableService", - "SetIamPolicy", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.setIamPolicy", + "TableService", + "SetIamPolicy", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -978,39 +974,39 @@ public void testTestIamPermissionsTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#testIamPermissionsResponse\"}"); rpc.testIamPermissionsSkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Arrays.asList("p1", "p2"), - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Arrays.asList("p1", "p2"), + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":testIamPermissions"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":testIamPermissions"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.testIamPermissions", - "TableService", - "TestIamPermissions", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.testIamPermissions", + "TableService", + "TestIamPermissions", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testOtelAttributesFromOptionsGetAddedtoSpan() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); Map options = new HashMap<>(); options.put(BigQueryRpc.Option.FIELDS, "foo,bar"); @@ -1022,44 +1018,44 @@ public void testOtelAttributesFromOptionsGetAddedtoSpan() throws Exception { expectedAttributes.put("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - expectedAttributes); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + expectedAttributes); } @Test public void testHttpTracingEnabledAddsAdditionalAttributes() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals("http", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.RPC_SYSTEM_NAME)); assertNotNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_SERVICE)); @@ -1068,25 +1064,25 @@ public void testHttpTracingEnabledAddsAdditionalAttributes() throws Exception { @Test public void testHttpTracingEnabled_GenericException_SetsAttributes() throws Exception { assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "java.io.IOException", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); + "java.io.IOException", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); assertEquals( - "CLIENT_UNKNOWN_ERROR", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); + "CLIENT_UNKNOWN_ERROR", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); } @Test @@ -1094,214 +1090,109 @@ public void testHttpTracingEnabled_JsonResponseException_SetsAttributes() throws mockResponse.setStatusCode(400); mockResponse.setContentType(Json.MEDIA_TYPE); mockResponse.setContent( - "{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}"); + "{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}"); assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals("invalid", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); assertEquals( - "Invalid request", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); + "Invalid request", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); } @Test public void testGetUriTemplateValueTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "projects/{+projectId}/datasets/{+datasetId}", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_TEMPLATE)); + "projects/{+projectId}/datasets/{+datasetId}", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_TEMPLATE)); } @Test public void testUrlDomain_DefaultValue() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "bigquery.googleapis.com", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); + "bigquery.googleapis.com", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); } @Test public void testUrlDomain_OverriddenValue() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); BigQueryOptions customOptions = - BigQueryOptions.newBuilder() - .setProjectId(PROJECT_ID) - .setCredentials(NoCredentials.getInstance()) - .setEnableOpenTelemetryTracing(true) - .setOpenTelemetryTracer(tracer) - .setTransportOptions( - BigQueryOptions.getDefaultHttpTransportOptions().toBuilder() - .setHttpTransportFactory(() -> mockTransport) - .build()) - .setHost("https://custom.googleapis.com") - .build(); + BigQueryOptions.newBuilder() + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .setEnableOpenTelemetryTracing(true) + .setOpenTelemetryTracer(tracer) + .setTransportOptions( + BigQueryOptions.getDefaultHttpTransportOptions().toBuilder() + .setHttpTransportFactory(() -> mockTransport) + .build()) + .setHost("https://custom.googleapis.com") + .build(); HttpBigQueryRpc customRpc = new HttpBigQueryRpc(customOptions); customRpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "custom.googleapis.com", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); - } - } - - @Nested - class TelemetryEnabledDevDisabled { - private HttpBigQueryRpc rpc; - - @BeforeEach - public void setUp() { - setUpServer(); - System.clearProperty("com.google.cloud.bigquery.http.tracing.dev.enabled"); - rpc = createRpc(true); - } - - @Test - public void testHttpTracingDisabledDoesNotAddAdditionalAttributes() throws Exception { - setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); - - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - - verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); - - List spans = spanExporter.getFinishedSpanItems(); - assertThat(spans).isNotEmpty(); - SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); - assertNotNull(rpcSpan); - verifySpanProductionAttributes( - "DatasetService", - "GetDataset", - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID), - rpcSpan); - - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.RPC_SYSTEM_NAME)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_SERVICE)); - assertNull( - rpcSpan.getAttributes().get(AttributeKey.stringKey("url.template")), - "url.template attribute should not be set"); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.GCP_RESOURCE_DESTINATION_ID)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); - assertNull( - rpcSpan.getAttributes().get(HttpTracingRequestInitializer.HTTP_REQUEST_RESEND_COUNT)); - } - - @Test - public void testHttpTracingDisabled_GenericException_DoesNotSetAttributes() throws Exception { - assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); - - List spans = spanExporter.getFinishedSpanItems(); - assertThat(spans).isNotEmpty(); - io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); - assertNotNull(rpcSpan); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); - } - - @Test - public void testHttpTracingDisabled_GoogleJsonResponseException_DoesNotSetAttributes() - throws Exception { - mockResponse.setStatusCode(400); - mockResponse.setContentType(Json.MEDIA_TYPE); - mockResponse.setContent( - "{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}"); - - assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); - - List spans = spanExporter.getFinishedSpanItems(); - assertThat(spans).isNotEmpty(); - io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); - assertNotNull(rpcSpan); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); - assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); + "custom.googleapis.com", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); } } @@ -1312,7 +1203,6 @@ class TelemetryDisabled { @BeforeEach public void setUp() { setUpServer(); - System.clearProperty("com.google.cloud.bigquery.http.tracing.dev.enabled"); rpc = createRpc(false); } From eb74808ec55fec8a977fd089186b9c8f0d0d4f81 Mon Sep 17 00:00:00 2001 From: ldetmer Date: Thu, 2 Apr 2026 11:21:36 -0400 Subject: [PATCH 2/4] format --- .../bigquery/spi/v2/HttpBigQueryRpc.java | 12 +- .../bigquery/spi/v2/HttpBigQueryRpcTest.java | 952 +++++++++--------- 2 files changed, 480 insertions(+), 484 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java index 587ad3fc3af7..b89cb99d4d64 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java @@ -118,8 +118,7 @@ public HttpBigQueryRpc(BigQueryOptions options) { this.options = options; this.urlDomain = new GenericUrl(options.getResolvedApiaryHost("bigquery")).getHost(); - if (options.isOpenTelemetryTracingEnabled() - && options.getOpenTelemetryTracer() != null) { + if (options.isOpenTelemetryTracingEnabled() && options.getOpenTelemetryTracer() != null) { initializer = new HttpTracingRequestInitializer(initializer, options.getOpenTelemetryTracer()); } @@ -2144,10 +2143,10 @@ private Span createRpcTracingSpan( .setAttribute("bq.rpc.service", service) .setAttribute("bq.rpc.method", method) .setAttribute("bq.rpc.system", "http") - .setAttribute( - BigQueryTelemetryTracer.GCP_RESOURCE_DESTINATION_ID, gcpResourceDestinationId) - .setAttribute(BigQueryTelemetryTracer.URL_TEMPLATE, urlTemplate) - .setAttribute(BigQueryTelemetryTracer.URL_DOMAIN, this.urlDomain); + .setAttribute( + BigQueryTelemetryTracer.GCP_RESOURCE_DESTINATION_ID, gcpResourceDestinationId) + .setAttribute(BigQueryTelemetryTracer.URL_TEMPLATE, urlTemplate) + .setAttribute(BigQueryTelemetryTracer.URL_DOMAIN, this.urlDomain); if (options != null) { builder.setAllAttributes(otelAttributesFromOptions(options)); @@ -2194,5 +2193,4 @@ private static Attributes otelAttributesFromOptions(Map options) { } return builder.build(); } - } diff --git a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java index 74d0371b10cc..33716417ed09 100644 --- a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java +++ b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java @@ -64,8 +64,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; public class HttpBigQueryRpcTest { @@ -228,76 +226,76 @@ public void setUp() { @Test public void testSpanEndOnError() { assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); // Verify that span was ended (collected) despite the error verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + null); } @Test public void testGetDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test public void testListDatasetsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#datasetList\",\"datasets\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#datasetList\",\"datasets\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listDatasetsSkipExceptionTranslation(PROJECT_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listDatasets", - "DatasetService", - "ListDatasets", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listDatasets", + "DatasetService", + "ListDatasets", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); Dataset dataset = new Dataset(); dataset.setDatasetReference( - new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); + new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); rpc.createSkipExceptionTranslation(dataset, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createDataset", - "DatasetService", - "InsertDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createDataset", + "DatasetService", + "InsertDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test @@ -309,99 +307,99 @@ public void testDeleteDatasetTelemetry() throws Exception { verifyRequest("DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteDataset", - "DatasetService", - "DeleteDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteDataset", + "DatasetService", + "DeleteDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + null); } @Test public void testPatchDatasetTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); Dataset dataset = new Dataset(); dataset.setDatasetReference( - new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); + new DatasetReference().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID)); rpc.patchSkipExceptionTranslation(dataset, new HashMap<>()); verifyRequest("PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchDataset", - "DatasetService", - "PatchDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchDataset", + "DatasetService", + "PatchDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); } @Test public void testGetTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); rpc.getTableSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getTable", - "TableService", - "GetTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getTable", + "TableService", + "GetTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test public void testListTablesTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#tableList\",\"tables\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#tableList\",\"tables\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listTablesSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTables", - "TableService", - "ListTables", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listTables", + "TableService", + "ListTables", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); Table table = new Table(); table.setTableReference( - new TableReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setTableId(TABLE_ID)); + new TableReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setTableId(TABLE_ID)); rpc.createSkipExceptionTranslation(table, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createTable", - "TableService", - "InsertTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createTable", + "TableService", + "InsertTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test @@ -412,111 +410,111 @@ public void testDeleteTableTelemetry() throws Exception { rpc.deleteTableSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID); verifyRequest( - "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteTable", - "TableService", - "DeleteTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteTable", + "TableService", + "DeleteTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testPatchTableTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#table\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "." - + TABLE_ID - + "\"}"); + "{\"kind\":\"bigquery#table\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "." + + TABLE_ID + + "\"}"); Table table = new Table(); table.setTableReference( - new TableReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setTableId(TABLE_ID)); + new TableReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setTableId(TABLE_ID)); rpc.patchSkipExceptionTranslation(table, new HashMap<>()); verifyRequest( - "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); + "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchTable", - "TableService", - "PatchTable", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Collections.singletonMap( - "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchTable", + "TableService", + "PatchTable", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Collections.singletonMap( + "bq.rpc.response.table.id", PROJECT_ID + ":" + DATASET_ID + "." + TABLE_ID)); } @Test public void testGetModelTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"modelId\":\"" - + MODEL_ID - + "\"}}"); + "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"modelId\":\"" + + MODEL_ID + + "\"}}"); rpc.getModelSkipExceptionTranslation(PROJECT_ID, DATASET_ID, MODEL_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getModel", - "ModelService", - "GetModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getModel", + "ModelService", + "GetModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); } @Test public void testListModelsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#modelList\",\"models\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#modelList\",\"models\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listModelsSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listModels", - "ModelService", - "ListModels", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listModels", + "ModelService", + "ListModels", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testPatchModelTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"modelId\":\"" - + MODEL_ID - + "\"}}"); + "{\"kind\":\"bigquery#model\",\"modelReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"modelId\":\"" + + MODEL_ID + + "\"}}"); Model model = new Model(); model.setModelReference( - new ModelReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setModelId(MODEL_ID)); + new ModelReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setModelId(MODEL_ID)); rpc.patchSkipExceptionTranslation(model, new HashMap<>()); verifyRequest( - "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "PATCH", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.patchModel", - "ModelService", - "PatchModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); + "com.google.cloud.bigquery.BigQueryRpc.patchModel", + "ModelService", + "PatchModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + Collections.singletonMap("bq.rpc.response.model.id", MODEL_ID)); } @Test @@ -527,90 +525,90 @@ public void testDeleteModelTelemetry() throws Exception { rpc.deleteModelSkipExceptionTranslation(PROJECT_ID, DATASET_ID, MODEL_ID); verifyRequest( - "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); + "DELETE", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteModel", - "ModelService", - "DeleteModel", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteModel", + "ModelService", + "DeleteModel", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/models/" + MODEL_ID, + null); } @Test public void testGetRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); rpc.getRoutineSkipExceptionTranslation(PROJECT_ID, DATASET_ID, ROUTINE_ID, new HashMap<>()); verifyRequest( - "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getRoutine", - "RoutineService", - "GetRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getRoutine", + "RoutineService", + "GetRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test public void testListRoutinesTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routineList\",\"routines\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#routineList\",\"routines\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listRoutinesSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listRoutines", - "RoutineService", - "ListRoutines", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listRoutines", + "RoutineService", + "ListRoutines", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); Routine routine = new Routine(); routine.setRoutineReference( - new RoutineReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setRoutineId(ROUTINE_ID)); + new RoutineReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setRoutineId(ROUTINE_ID)); rpc.createSkipExceptionTranslation(routine, new HashMap<>()); verifyRequest("POST", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createRoutine", - "RoutineService", - "InsertRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.createRoutine", + "RoutineService", + "InsertRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test @@ -621,53 +619,53 @@ public void testDeleteRoutineTelemetry() throws Exception { rpc.deleteRoutineSkipExceptionTranslation(PROJECT_ID, DATASET_ID, ROUTINE_ID); verifyRequest( - "DELETE", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "DELETE", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteRoutine", - "RoutineService", - "DeleteRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteRoutine", + "RoutineService", + "DeleteRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + null); } @Test public void testUpdateRoutineTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\",\"routineId\":\"" - + ROUTINE_ID - + "\"}}"); + "{\"kind\":\"bigquery#routine\",\"routineReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\",\"routineId\":\"" + + ROUTINE_ID + + "\"}}"); Routine routine = new Routine(); routine.setRoutineReference( - new RoutineReference() - .setProjectId(PROJECT_ID) - .setDatasetId(DATASET_ID) - .setRoutineId(ROUTINE_ID)); + new RoutineReference() + .setProjectId(PROJECT_ID) + .setDatasetId(DATASET_ID) + .setRoutineId(ROUTINE_ID)); rpc.updateSkipExceptionTranslation(routine, new HashMap<>()); verifyRequest( - "PUT", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); + "PUT", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/routines/" + ROUTINE_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.updateRoutine", - "RoutineService", - "UpdateRoutine", - RESOURCE_PROJECT_PREFIX - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/routines/" - + ROUTINE_ID, - Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); + "com.google.cloud.bigquery.BigQueryRpc.updateRoutine", + "RoutineService", + "UpdateRoutine", + RESOURCE_PROJECT_PREFIX + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/routines/" + + ROUTINE_ID, + Collections.singletonMap("bq.rpc.response.routine.id", ROUTINE_ID)); } @Test @@ -678,20 +676,20 @@ public void testInsertAllTelemetry() throws Exception { rpc.insertAllSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, request); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + "/insertAll"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + "/insertAll"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.insertAll", - "TableDataService", - "InsertAll", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.insertAll", + "TableDataService", + "InsertAll", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -701,14 +699,14 @@ public void testListTableDataTelemetry() throws Exception { rpc.listTableDataSkipExceptionTranslation(PROJECT_ID, DATASET_ID, TABLE_ID, new HashMap<>()); verifyRequest( - "GET", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); + "GET", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTableData", - "TableDataService", - "List", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.listTableData", + "TableDataService", + "List", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -716,27 +714,27 @@ public void testListTableDataWithRowLimitTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#tableDataList\",\"rows\":[]}"); rpc.listTableDataWithRowLimitSkipExceptionTranslation( - PROJECT_ID, DATASET_ID, TABLE_ID, 10, null); + PROJECT_ID, DATASET_ID, TABLE_ID, 10, null); verifyRequest( - "GET", - "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); + "GET", + "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID + "/data"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listTableDataWithRowLimit", - "TableDataService", - "List", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.listTableDataWithRowLimit", + "TableDataService", + "List", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testGetJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); rpc.getJobSkipExceptionTranslation(PROJECT_ID, JOB_ID, LOCATION, new HashMap<>()); @@ -745,21 +743,21 @@ public void testGetJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getJob", - "JobService", - "GetJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - attributes); + "com.google.cloud.bigquery.BigQueryRpc.getJob", + "JobService", + "GetJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + attributes); } @Test public void testGetQueryJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); rpc.getQueryJobSkipExceptionTranslation(PROJECT_ID, JOB_ID, LOCATION); @@ -768,37 +766,37 @@ public void testGetQueryJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryJob", - "JobService", - "GetJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - attributes); + "com.google.cloud.bigquery.BigQueryRpc.getQueryJob", + "JobService", + "GetJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + attributes); } @Test public void testListJobsTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#jobList\",\"jobs\":[], \"nextPageToken\":\"next-page-token\"}"); + "{\"kind\":\"bigquery#jobList\",\"jobs\":[], \"nextPageToken\":\"next-page-token\"}"); rpc.listJobsSkipExceptionTranslation(PROJECT_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/jobs"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.listJobs", - "JobService", - "ListJobs", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); + "com.google.cloud.bigquery.BigQueryRpc.listJobs", + "JobService", + "ListJobs", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + Collections.singletonMap("bq.rpc.next_page_token", "next-page-token")); } @Test public void testCreateJobTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); Job job = new Job(); job.setJobReference(new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID)); @@ -809,21 +807,21 @@ public void testCreateJobTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createJob", - "JobService", - "InsertJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - attributes); + "com.google.cloud.bigquery.BigQueryRpc.createJob", + "JobService", + "InsertJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + attributes); } @Test public void testCreateJobForQueryTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#job\",\"id\":\"" - + PROJECT_ID - + ":" - + JOB_ID - + "\",\"status\":{\"state\":\"DONE\"}}"); + "{\"kind\":\"bigquery#job\",\"id\":\"" + + PROJECT_ID + + ":" + + JOB_ID + + "\",\"status\":{\"state\":\"DONE\"}}"); Job job = new Job(); job.setJobReference(new JobReference().setProjectId(PROJECT_ID).setJobId(JOB_ID)); @@ -834,11 +832,11 @@ public void testCreateJobForQueryTelemetry() throws Exception { attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID); attributes.put("bq.rpc.response.job.status.state", "DONE"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.createJobForQuery", - "JobService", - "InsertJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - attributes); + "com.google.cloud.bigquery.BigQueryRpc.createJobForQuery", + "JobService", + "InsertJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + attributes); } @Test @@ -849,11 +847,11 @@ public void testCancelJobTelemetry() throws Exception { verifyRequest("POST", "/projects/" + PROJECT_ID + "/jobs/" + JOB_ID + "/cancel"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.cancelJob", - "JobService", - "CancelJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.cancelJob", + "JobService", + "CancelJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -865,11 +863,11 @@ public void testDeleteJobTelemetry() throws Exception { verifyRequest("DELETE", "/projects/" + PROJECT_ID + "/jobs/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.deleteJob", - "JobService", - "DeleteJob", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.deleteJob", + "JobService", + "DeleteJob", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -880,11 +878,11 @@ public void testGetQueryResultsTelemetry() throws Exception { verifyRequest("GET", "/projects/" + PROJECT_ID + "/queries/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryResults", - "JobService", - "GetQueryResults", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getQueryResults", + "JobService", + "GetQueryResults", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -892,15 +890,15 @@ public void testGetQueryResultsWithRowLimitTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#getQueryResultsResponse\"}"); rpc.getQueryResultsWithRowLimitSkipExceptionTranslation( - PROJECT_ID, JOB_ID, LOCATION, 10, 1000L); + PROJECT_ID, JOB_ID, LOCATION, 10, 1000L); verifyRequest("GET", "/projects/" + PROJECT_ID + "/queries/" + JOB_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getQueryResultsWithRowLimit", - "JobService", - "GetQueryResults", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getQueryResultsWithRowLimit", + "JobService", + "GetQueryResults", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs/" + JOB_ID, + null); } @Test @@ -911,11 +909,11 @@ public void testQueryRpcTelemetry() throws Exception { verifyRequest("POST", "/projects/" + PROJECT_ID + "/queries"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.queryRpc", - "JobService", - "Query", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", - null); + "com.google.cloud.bigquery.BigQueryRpc.queryRpc", + "JobService", + "Query", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/jobs", + null); } @Test @@ -923,24 +921,24 @@ public void testGetIamPolicyTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#policy\"}"); rpc.getIamPolicySkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":getIamPolicy"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":getIamPolicy"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getIamPolicy", - "TableService", - "GetIamPolicy", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.getIamPolicy", + "TableService", + "GetIamPolicy", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -948,25 +946,25 @@ public void testSetIamPolicyTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#policy\"}"); rpc.setIamPolicySkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - new Policy(), - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + new Policy(), + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":setIamPolicy"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":setIamPolicy"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.setIamPolicy", - "TableService", - "SetIamPolicy", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.setIamPolicy", + "TableService", + "SetIamPolicy", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test @@ -974,39 +972,39 @@ public void testTestIamPermissionsTelemetry() throws Exception { setMockResponse("{\"kind\":\"bigquery#testIamPermissionsResponse\"}"); rpc.testIamPermissionsSkipExceptionTranslation( - "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - Arrays.asList("p1", "p2"), - new HashMap<>()); + "projects/" + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + Arrays.asList("p1", "p2"), + new HashMap<>()); verifyRequest( - "POST", - "/projects/" - + PROJECT_ID - + "/datasets/" - + DATASET_ID - + "/tables/" - + TABLE_ID - + ":testIamPermissions"); + "POST", + "/projects/" + + PROJECT_ID + + "/datasets/" + + DATASET_ID + + "/tables/" + + TABLE_ID + + ":testIamPermissions"); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.testIamPermissions", - "TableService", - "TestIamPermissions", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, - null); + "com.google.cloud.bigquery.BigQueryRpc.testIamPermissions", + "TableService", + "TestIamPermissions", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID + "/tables/" + TABLE_ID, + null); } @Test public void testOtelAttributesFromOptionsGetAddedtoSpan() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); Map options = new HashMap<>(); options.put(BigQueryRpc.Option.FIELDS, "foo,bar"); @@ -1018,44 +1016,44 @@ public void testOtelAttributesFromOptionsGetAddedtoSpan() throws Exception { expectedAttributes.put("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - expectedAttributes); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + expectedAttributes); } @Test public void testHttpTracingEnabledAddsAdditionalAttributes() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); verifyRequest("GET", "/projects/" + PROJECT_ID + "/datasets/" + DATASET_ID); verifySpan( - "com.google.cloud.bigquery.BigQueryRpc.getDataset", - "DatasetService", - "GetDataset", - RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, - Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); + "com.google.cloud.bigquery.BigQueryRpc.getDataset", + "DatasetService", + "GetDataset", + RESOURCE_PROJECT_PREFIX + PROJECT_ID + "/datasets/" + DATASET_ID, + Collections.singletonMap("bq.rpc.response.dataset.id", PROJECT_ID + ":" + DATASET_ID)); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals("http", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.RPC_SYSTEM_NAME)); assertNotNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_SERVICE)); @@ -1064,25 +1062,25 @@ public void testHttpTracingEnabledAddsAdditionalAttributes() throws Exception { @Test public void testHttpTracingEnabled_GenericException_SetsAttributes() throws Exception { assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "java.io.IOException", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); + "java.io.IOException", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); assertEquals( - "CLIENT_UNKNOWN_ERROR", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); + "CLIENT_UNKNOWN_ERROR", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); } @Test @@ -1090,109 +1088,109 @@ public void testHttpTracingEnabled_JsonResponseException_SetsAttributes() throws mockResponse.setStatusCode(400); mockResponse.setContentType(Json.MEDIA_TYPE); mockResponse.setContent( - "{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}"); + "{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}"); assertThrows( - IOException.class, - () -> { - rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); - }); + IOException.class, + () -> { + rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); + }); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals("invalid", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE)); assertEquals( - "Invalid request", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); + "Invalid request", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.STATUS_MESSAGE)); assertNull(rpcSpan.getAttributes().get(BigQueryTelemetryTracer.EXCEPTION_TYPE)); } @Test public void testGetUriTemplateValueTelemetry() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" - + PROJECT_ID - + ":" - + DATASET_ID - + "\",\"datasetReference\":{\"projectId\":\"" - + PROJECT_ID - + "\",\"datasetId\":\"" - + DATASET_ID - + "\"}}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + + PROJECT_ID + + ":" + + DATASET_ID + + "\",\"datasetReference\":{\"projectId\":\"" + + PROJECT_ID + + "\",\"datasetId\":\"" + + DATASET_ID + + "\"}}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); assertThat(spans).isNotEmpty(); SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "projects/{+projectId}/datasets/{+datasetId}", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_TEMPLATE)); + "projects/{+projectId}/datasets/{+datasetId}", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_TEMPLATE)); } @Test public void testUrlDomain_DefaultValue() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); rpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "bigquery.googleapis.com", - rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); + "bigquery.googleapis.com", + rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); } @Test public void testUrlDomain_OverriddenValue() throws Exception { setMockResponse( - "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); + "{\"kind\":\"bigquery#dataset\",\"id\":\"" + PROJECT_ID + ":" + DATASET_ID + "\"}"); BigQueryOptions customOptions = - BigQueryOptions.newBuilder() - .setProjectId(PROJECT_ID) - .setCredentials(NoCredentials.getInstance()) - .setEnableOpenTelemetryTracing(true) - .setOpenTelemetryTracer(tracer) - .setTransportOptions( - BigQueryOptions.getDefaultHttpTransportOptions().toBuilder() - .setHttpTransportFactory(() -> mockTransport) - .build()) - .setHost("https://custom.googleapis.com") - .build(); + BigQueryOptions.newBuilder() + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .setEnableOpenTelemetryTracing(true) + .setOpenTelemetryTracer(tracer) + .setTransportOptions( + BigQueryOptions.getDefaultHttpTransportOptions().toBuilder() + .setHttpTransportFactory(() -> mockTransport) + .build()) + .setHost("https://custom.googleapis.com") + .build(); HttpBigQueryRpc customRpc = new HttpBigQueryRpc(customOptions); customRpc.getDatasetSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>()); List spans = spanExporter.getFinishedSpanItems(); io.opentelemetry.sdk.trace.data.SpanData rpcSpan = - spans.stream() - .filter( - span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) - .findFirst() - .orElse(null); + spans.stream() + .filter( + span -> span.getName().equals("com.google.cloud.bigquery.BigQueryRpc.getDataset")) + .findFirst() + .orElse(null); assertNotNull(rpcSpan); assertEquals( - "custom.googleapis.com", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); + "custom.googleapis.com", rpcSpan.getAttributes().get(BigQueryTelemetryTracer.URL_DOMAIN)); } } From ff492d68e25aa0a4d70d802c2602eaa4ffa1ea36 Mon Sep 17 00:00:00 2001 From: ldetmer Date: Thu, 2 Apr 2026 11:36:23 -0400 Subject: [PATCH 3/4] remove betaapi --- .../java/com/google/cloud/bigquery/BigQueryOptions.java | 7 ++----- .../cloud/bigquery/telemetry/BigQueryTelemetryTracer.java | 2 -- .../com/google/cloud/bigquery/telemetry/ErrorTypeUtil.java | 2 -- .../bigquery/telemetry/HttpTracingRequestInitializer.java | 2 -- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java index 10ae77930c85..a5e71a86fb1b 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java @@ -16,7 +16,6 @@ package com.google.cloud.bigquery; -import com.google.api.core.BetaApi; import com.google.api.core.ObsoleteApi; import com.google.api.gax.retrying.ResultRetryAlgorithm; import com.google.cloud.ServiceDefaults; @@ -127,9 +126,10 @@ public Builder setDataFormatOptions(DataFormatOptions dataFormatOptions) { /** * Enables OpenTelemetry tracing functionality for this BigQuery instance * + *

[TODO] add warning text here + * * @param enableOpenTelemetryTracing enables OpenTelemetry tracing if true */ - @BetaApi public Builder setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) { this.enableOpenTelemetryTracing = enableOpenTelemetryTracing; return this; @@ -140,7 +140,6 @@ public Builder setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) * * @param tracer OpenTelemetry tracer to be used */ - @BetaApi public Builder setOpenTelemetryTracer(Tracer tracer) { this.openTelemetryTracer = tracer; return this; @@ -282,7 +281,6 @@ public JobCreationMode getDefaultJobCreationMode() { * * @return true if tracing is enabled, false if not */ - @BetaApi("Span names and attributes are subject to change without notice") public boolean isOpenTelemetryTracingEnabled() { return enableOpenTelemetryTracing; } @@ -292,7 +290,6 @@ public boolean isOpenTelemetryTracingEnabled() { * * @return OpenTelemetry tracer object or {@code null} if not set */ - @BetaApi("Span names and attributes are subject to change without notice") public Tracer getOpenTelemetryTracer() { return openTelemetryTracer; } diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracer.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracer.java index 559ed6632a53..091b0793d0b4 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracer.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracer.java @@ -18,14 +18,12 @@ import com.google.api.client.googleapis.json.GoogleJsonError; import com.google.api.client.googleapis.json.GoogleJsonResponseException; -import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; /** BigQuery Telemetry class that stores generic telemetry attributes and values */ -@BetaApi @InternalApi public final class BigQueryTelemetryTracer { diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/ErrorTypeUtil.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/ErrorTypeUtil.java index c769fbb19e65..19d947811629 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/ErrorTypeUtil.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/ErrorTypeUtil.java @@ -15,7 +15,6 @@ */ package com.google.cloud.bigquery.telemetry; -import com.google.api.core.BetaApi; import com.google.common.annotations.VisibleForTesting; /** @@ -23,7 +22,6 @@ * replaced with gax version when ready work tracked in * https://github.com/googleapis/google-cloud-java/issues/12105 */ -@BetaApi @VisibleForTesting public class ErrorTypeUtil { diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java index 35ab902bd0e8..20b647bef9c1 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java @@ -17,7 +17,6 @@ package com.google.cloud.bigquery.telemetry; import com.google.api.client.http.*; -import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import com.google.cloud.bigquery.BigQueryRetryHelper; import com.google.common.annotations.VisibleForTesting; @@ -33,7 +32,6 @@ * HttpRequestInitializer that wraps a delegate initializer, intercepts all HTTP requests, adds * OpenTelemetry tracing and then invokes delegate interceptor. */ -@BetaApi @InternalApi public class HttpTracingRequestInitializer implements HttpRequestInitializer { From e871169e21f7eb2c6081086b5ae9fee66f7355af Mon Sep 17 00:00:00 2001 From: ldetmer Date: Fri, 3 Apr 2026 16:43:32 -0400 Subject: [PATCH 4/4] add javadoc warning --- .../cloud/bigquery/BigQueryOptions.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java index a5e71a86fb1b..d0c989ae0841 100644 --- a/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java +++ b/java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java @@ -126,7 +126,18 @@ public Builder setDataFormatOptions(DataFormatOptions dataFormatOptions) { /** * Enables OpenTelemetry tracing functionality for this BigQuery instance * - *

[TODO] add warning text here + *

Traces may contain sensitive data such as resource names, full URLs, + * and error messages. + * + *

Before configuring subscribers or exporters for traces, review the contents of the spans + * and consult the OpenTelemetry + * documentation to set up filters and formatters to prevent leaking sensitive information, + * depending on your intended use case. + * + *

See also: OpenTelemetry Semantic + * Conventions

* * @param enableOpenTelemetryTracing enables OpenTelemetry tracing if true */ @@ -138,6 +149,19 @@ public Builder setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) /** * Sets the OpenTelemetry tracer for this BigQuery instance to be tracer. * + *

Traces may contain sensitive data such as resource names, full URLs, + * and error messages. + * + *

Before configuring subscribers or exporters for traces, review the contents of the spans + * and consult the OpenTelemetry + * documentation to set up filters and formatters to prevent leaking sensitive information, + * depending on your intended use case. + * + *

See also: OpenTelemetry Semantic + * Conventions

+ * * @param tracer OpenTelemetry tracer to be used */ public Builder setOpenTelemetryTracer(Tracer tracer) {