Skip to content
6 changes: 6 additions & 0 deletions google-cloud-bigquery/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<differences>
<!-- TODO: REMOVE AFTER RELEASE -->
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/bigquery/BigQueryRetryHelper</className>
<method>java.lang.Object runWithRetries(java.util.concurrent.Callable, com.google.api.gax.retrying.RetrySettings, com.google.api.gax.retrying.ResultRetryAlgorithm, com.google.api.core.ApiClock, com.google.cloud.bigquery.BigQueryRetryConfig)</method>
<justification>A Tracer object is needed to use Otel and runWithRetries is only called in a few files, so it should be fine to update the signature</justification>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/bigquery/spi/v2/BigQueryRpc</className>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -340,7 +342,9 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -394,7 +398,9 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -488,7 +494,9 @@ public com.google.api.services.bigquery.model.Job call() throws IOException {
getOptions().getClock(),
getBigQueryRetryConfig(optionsMap) != null
? getBigQueryRetryConfig(optionsMap)
: DEFAULT_RETRY_CONFIG));
: DEFAULT_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
}
Expand Down Expand Up @@ -580,7 +588,9 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return Dataset.fromPb(this, answer);
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
Expand Down Expand Up @@ -644,7 +654,9 @@ private static Page<Dataset> listDatasets(
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.x();
return new PageImpl<>(
new DatasetPageFetcher(projectId, serviceOptions, cursor, optionsMap),
Expand Down Expand Up @@ -694,7 +706,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
return false;
Expand Down Expand Up @@ -743,7 +757,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
return false;
Expand Down Expand Up @@ -787,7 +803,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
return false;
Expand Down Expand Up @@ -831,7 +849,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
return false;
Expand Down Expand Up @@ -873,7 +893,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -912,7 +934,9 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -957,7 +981,9 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -1001,7 +1027,9 @@ public com.google.api.services.bigquery.model.Model call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -1045,7 +1073,9 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -1097,7 +1127,9 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return Table.fromPb(this, answer);
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
Expand Down Expand Up @@ -1154,7 +1186,9 @@ public com.google.api.services.bigquery.model.Model call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return Model.fromPb(this, answer);
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
Expand Down Expand Up @@ -1211,7 +1245,9 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return Routine.fromPb(this, answer);
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
Expand Down Expand Up @@ -1427,7 +1463,9 @@ public Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> cal
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.x();
Iterable<Table> tables =
Iterables.transform(
Expand Down Expand Up @@ -1466,7 +1504,9 @@ public Tuple<String, Iterable<com.google.api.services.bigquery.model.Model>> cal
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.x();
Iterable<Model> models =
Iterables.transform(
Expand Down Expand Up @@ -1505,7 +1545,9 @@ private static Page<Routine> listRoutines(
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.x();
Iterable<Routine> routines =
Iterables.transform(
Expand Down Expand Up @@ -1585,7 +1627,9 @@ public TableDataInsertAllResponse call() throws Exception {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
}
Expand Down Expand Up @@ -1677,7 +1721,9 @@ public TableDataList call() throws IOException {
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.getPageToken();
Map<BigQueryRpc.Option, ?> pageOptionMap =
Strings.isNullOrEmpty(cursor) ? optionsMap : optionMap(TableDataListOption.startIndex(0));
Expand Down Expand Up @@ -1749,7 +1795,9 @@ public com.google.api.services.bigquery.model.Job call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return Job.fromPb(this, answer);
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
Expand Down Expand Up @@ -1804,7 +1852,9 @@ public Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> call(
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());
String cursor = result.x();
Iterable<Job> jobs =
Iterables.transform(
Expand Down Expand Up @@ -1857,7 +1907,9 @@ public Boolean call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelperException e) {
if (isRetryErrorCodeHttpNotFound(e)) {
return false;
Expand Down Expand Up @@ -1942,7 +1994,9 @@ public com.google.api.services.bigquery.model.QueryResponse call()
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
DEFAULT_RETRY_CONFIG);
DEFAULT_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
} catch (BigQueryRetryHelper.BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -2117,7 +2171,9 @@ public GetQueryResultsResponse call() throws IOException {
serviceOptions.getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
serviceOptions.getClock(),
DEFAULT_RETRY_CONFIG);
DEFAULT_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());

TableSchema schemaPb = results.getSchema();

Expand Down Expand Up @@ -2186,7 +2242,9 @@ public com.google.api.services.bigquery.model.Policy call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -2230,7 +2288,9 @@ public com.google.api.services.bigquery.model.Policy call() throws IOException {
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG));
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer()));
} catch (BigQueryRetryHelperException e) {
throw BigQueryException.translateAndThrow(e);
} finally {
Expand Down Expand Up @@ -2276,7 +2336,9 @@ public com.google.api.services.bigquery.model.TestIamPermissionsResponse call()
getOptions().getRetrySettings(),
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
getOptions().getClock(),
EMPTY_RETRY_CONFIG);
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
getOptions().getOpenTelemetryTracer());
return response.getPermissions() == null
? ImmutableList.of()
: ImmutableList.copyOf(response.getPermissions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import com.google.api.gax.retrying.RetryingFuture;
import com.google.api.gax.retrying.TimedRetryAlgorithm;
import com.google.cloud.RetryHelper;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
Expand All @@ -40,9 +43,18 @@ public static <V> V runWithRetries(
RetrySettings retrySettings,
ResultRetryAlgorithm<?> resultRetryAlgorithm,
ApiClock clock,
BigQueryRetryConfig bigQueryRetryConfig)
BigQueryRetryConfig bigQueryRetryConfig,
boolean isOpenTelemetryEnabled,
Tracer openTelemetryTracer)
throws RetryHelperException {
try {
Span runWithRetries = null;
if (isOpenTelemetryEnabled && openTelemetryTracer != null) {
runWithRetries =
openTelemetryTracer
.spanBuilder("com.google.cloud.bigquery.BigQueryRetryHelper.runWithRetries")
.startSpan();
}
try (Scope runWithRetriesScope = runWithRetries != null ? runWithRetries.makeCurrent() : null) {
// Suppressing should be ok as a workaraund. Current and only ResultRetryAlgorithm
// implementation does not use response at all, so ignoring its type is ok.
@SuppressWarnings("unchecked")
Expand All @@ -59,6 +71,10 @@ public static <V> V runWithRetries(
throw new BigQueryRetryHelperException(new BigQueryException((IOException) e.getCause()));
}
throw new BigQueryRetryHelperException(e.getCause());
} finally {
if (runWithRetries != null) {
runWithRetries.end();
}
}
}

Expand Down
Loading