Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,25 @@ public class BigtableOptionsFactory {
@VisibleForTesting
public static final String BIGTABLE_TEST_IDLE_TIMEOUT_MS = "google.bigtable.idle.timeout.ms";

/** Sets if client side metrics should be enabled. Client side metrics is enabled by default. */
/**
* Sets whether client-side metrics should be enabled. Enabled by default.
*
* <p>Setting this to {@code false} configures the client-side {@link
* com.google.cloud.bigtable.data.v2.stub.metrics.MetricsProvider} to {@link
* com.google.cloud.bigtable.data.v2.stub.metrics.NoopMetricsProvider#INSTANCE}. This does not
* disable exporting built-in internal metrics to Cloud Monitoring, which is controlled separately
* by {@link #BIGTABLE_ENABLE_INTERNAL_METRICS}.
*/
public static final String BIGTABLE_ENABLE_CLIENT_SIDE_METRICS =
"google.bigtable.enable.client.side.metrics";

/**
* Sets whether built-in internal metrics exported to Cloud Monitoring should be enabled. Enabled
* by default. Set to {@code false} to disable exporting built-in metrics to Cloud Monitoring.
*/
public static final String BIGTABLE_ENABLE_INTERNAL_METRICS =
"google.bigtable.enable.internal.metrics";

/** Override jwt audience in test environment. * */
@InternalApi
public static final String BIGTABLE_JWT_AUDIENCE_KEY = "google.bigtable.jwt.audience";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_EMULATOR_HOST_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_ENABLE_BULK_MUTATION_FLOW_CONTROL;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_ENABLE_CLIENT_SIDE_METRICS;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_ENABLE_INTERNAL_METRICS;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_HOST_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_JWT_AUDIENCE_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_MUTATE_RPC_ATTEMPT_TIMEOUT_MS_KEY;
Expand Down Expand Up @@ -368,6 +369,10 @@ private BigtableDataSettings buildBigtableDataSettings(ClientOperationTimeouts c
dataBuilder.setMetricsProvider(NoopMetricsProvider.INSTANCE);
}

if (!configuration.getBoolean(BIGTABLE_ENABLE_INTERNAL_METRICS, true)) {
dataBuilder.disableInternalMetrics();
}

return dataBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_BULK_MAX_ROW_KEY_COUNT;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_DATA_CHANNEL_COUNT_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_EMULATOR_HOST_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_ENABLE_CLIENT_SIDE_METRICS;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_ENABLE_INTERNAL_METRICS;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_NULL_CREDENTIAL_ENABLE_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_PORT_KEY;
import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_READ_RPC_ATTEMPT_TIMEOUT_MS_KEY;
Expand Down Expand Up @@ -62,6 +64,8 @@
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
import com.google.cloud.bigtable.data.v2.models.Query;
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.cloud.bigtable.data.v2.stub.metrics.DefaultMetricsProvider;
import com.google.cloud.bigtable.data.v2.stub.metrics.NoopMetricsProvider;
import com.google.cloud.bigtable.hbase.BigtableConfiguration;
import com.google.cloud.bigtable.hbase.BigtableHBaseVersion;
import com.google.cloud.bigtable.hbase.BigtableOptionsFactory;
Expand Down Expand Up @@ -561,6 +565,48 @@ public void testAdminSettingsWithEmulator() throws IOException {
assertTrue(credProvider instanceof NoCredentialsProvider);
}

@Test
public void testInternalMetricsEnabledByDefault() throws IOException {
BigtableHBaseVeneerSettings settings = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings dataSettings = settings.getDataSettings();

assertTrue(dataSettings.areInternalMetricsEnabled());
assertEquals(DefaultMetricsProvider.INSTANCE, dataSettings.getMetricsProvider());
}

@Test
public void testDisableInternalMetrics() throws IOException {
configuration.set(BIGTABLE_ENABLE_INTERNAL_METRICS, "false");

BigtableHBaseVeneerSettings settings = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings dataSettings = settings.getDataSettings();

assertFalse(dataSettings.areInternalMetricsEnabled());
assertEquals(DefaultMetricsProvider.INSTANCE, dataSettings.getMetricsProvider());
}

@Test
public void testEnableInternalMetricsExplicitly() throws IOException {
configuration.set(BIGTABLE_ENABLE_INTERNAL_METRICS, "true");

BigtableHBaseVeneerSettings settings = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings dataSettings = settings.getDataSettings();

assertTrue(dataSettings.areInternalMetricsEnabled());
assertEquals(DefaultMetricsProvider.INSTANCE, dataSettings.getMetricsProvider());
}

@Test
public void testDisableClientSideMetricsDoesNotDisableInternalMetrics() throws IOException {
configuration.set(BIGTABLE_ENABLE_CLIENT_SIDE_METRICS, "false");

BigtableHBaseVeneerSettings settings = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings dataSettings = settings.getDataSettings();

assertEquals(NoopMetricsProvider.INSTANCE, dataSettings.getMetricsProvider());
assertTrue(dataSettings.areInternalMetricsEnabled());
}

@Ignore("Re-enable this test once veneer default align with hbase")
@Test
public void testRpcMethodWithoutRetry() throws IOException {
Expand Down
Loading