Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Nov 27, 2024
1 parent 54da85e commit 5b52500
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.cloud.bigtable.data.v2.stub.BigtableBatchingCallSettings;
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings;
import com.google.cloud.bigtable.data.v2.stub.metrics.MetricsProvider;
import com.google.cloud.bigtable.data.v2.stub.metrics.NoopMetricsProvider;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import io.grpc.ManagedChannelBuilder;
Expand Down Expand Up @@ -127,6 +128,7 @@ public static Builder newBuilderForEmulator(String hostname, int port) {
.setEndpoint(hostname + ":" + port)
// disable channel refreshing when creating an emulator
.setRefreshingChannel(false)
.setMetricsProvider(NoopMetricsProvider.INSTANCE) // disable exporting metrics for emulator
.setTransportChannelProvider(
InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(256 * 1024 * 1024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ public static BigtableClientContext create(EnhancedBigtableStubSettings settings
// the OTEL instance and log the exception instead.
openTelemetry =
getOpenTelemetryFromMetricsProvider(
settings.getMetricsProvider(),
credentials,
settings.getMetricsEndpoint());
settings.getMetricsProvider(), credentials, settings.getMetricsEndpoint());
} catch (Throwable t) {
logger.log(Level.WARNING, "Failed to get OTEL, will skip exporting client side metrics", t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@

import com.google.api.core.InternalApi;
import com.google.auth.Credentials;
<<<<<<< HEAD
import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects;
=======
>>>>>>> main
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;

/**
Expand All @@ -45,8 +39,7 @@ private DefaultMetricsProvider() {}

@InternalApi
public OpenTelemetry getOpenTelemetry(
@Nullable String metricsEndpoint, @Nullable Credentials credentials)
throws IOException {
@Nullable String metricsEndpoint, @Nullable Credentials credentials) throws IOException {
SdkMeterProviderBuilder meterProvider = SdkMeterProvider.builder();
BuiltinMetricsView.registerBuiltinMetrics(credentials, meterProvider, metricsEndpoint);
return OpenTelemetrySdk.builder().setMeterProvider(meterProvider.build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,15 +825,16 @@ public void testExecuteQueryWaitTimeoutWorksWithMetadataFuture()
settings.setStreamWatchdogProvider(
InstantiatingWatchdogProvider.create().withCheckInterval(WATCHDOG_CHECK_DURATION));

EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build());
ApiFuture<ResultSetMetadata> future =
stub.executeQueryCallable().call(Statement.of(WAIT_TIME_QUERY)).metadataFuture();

ExecutionException e = assertThrows(ExecutionException.class, future::get);
assertThat(e.getCause()).isInstanceOf(WatchdogTimeoutException.class);
assertThat(e.getCause().getMessage())
.contains("Canceled due to timeout waiting for next response");
assertThat(e).hasMessageThat().contains("Canceled due to timeout waiting for next response");
try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build())) {
ApiFuture<ResultSetMetadata> future =
stub.executeQueryCallable().call(Statement.of(WAIT_TIME_QUERY)).metadataFuture();

ExecutionException e = assertThrows(ExecutionException.class, future::get);
assertThat(e.getCause()).isInstanceOf(WatchdogTimeoutException.class);
assertThat(e.getCause().getMessage())
.contains("Canceled due to timeout waiting for next response");
assertThat(e).hasMessageThat().contains("Canceled due to timeout waiting for next response");
}
}

private static class MetadataInterceptor implements ServerInterceptor {
Expand Down

This file was deleted.

0 comments on commit 5b52500

Please sign in to comment.