use of com.google.cloud.bigtable.hbase.wrappers.veneer.metrics.MetricsApiTracerAdapterFactory in project java-bigtable-hbase by googleapis.
the class TestBigtableHBaseVeneerSettings method testDataSettingsBasicKeys.
@Test
public void testDataSettingsBasicKeys() throws IOException {
String appProfileId = "appProfileId";
String userAgent = "test-user-agent";
String fakeTracingCookie = "fake-tracing-cookie";
Credentials credentials = Mockito.mock(Credentials.class);
configuration.set(BIGTABLE_PORT_KEY, String.valueOf(TEST_PORT));
configuration.set(APP_PROFILE_ID_KEY, appProfileId);
configuration.setBoolean(BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true);
configuration.set(CUSTOM_USER_AGENT_KEY, userAgent);
configuration.set(BIGTABLE_USE_CACHED_DATA_CHANNEL_POOL, "true");
configuration.set(BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, "true");
configuration.set(ALLOW_NO_TIMESTAMP_RETRIES_KEY, "true");
configuration.set(BIGTABLE_TRACING_COOKIE, fakeTracingCookie);
configuration = BigtableConfiguration.withCredentials(configuration, credentials);
BigtableHBaseVeneerSettings settingUtils = (BigtableHBaseVeneerSettings) BigtableHBaseSettings.create(configuration);
BigtableDataSettings dataSettings = settingUtils.getDataSettings();
assertEquals(TEST_PROJECT_ID, dataSettings.getProjectId());
assertEquals(TEST_INSTANCE_ID, dataSettings.getInstanceId());
assertEquals(appProfileId, dataSettings.getAppProfileId());
assertEquals(TEST_HOST, settingUtils.getDataHost());
assertEquals(TEST_PORT, settingUtils.getPort());
assertEquals(TEST_HOST, settingUtils.getAdminHost());
assertEquals(TEST_HOST + ":" + TEST_PORT, dataSettings.getStubSettings().getEndpoint());
Map<String, String> headers = dataSettings.getStubSettings().getHeaderProvider().getHeaders();
assertTrue(headers.get(GrpcUtil.USER_AGENT_KEY.name()).contains(userAgent));
assertTrue(headers.get(GrpcUtil.USER_AGENT_KEY.name()).contains("bigtable-hbase/" + BigtableHBaseVersion.getVersion()));
assertTrue(headers.get("cookie").equals(fakeTracingCookie));
assertEquals(credentials, dataSettings.getStubSettings().getCredentialsProvider().getCredentials());
assertTrue(settingUtils.isChannelPoolCachingEnabled());
assertTrue(settingUtils.isRetriesWithoutTimestampAllowed());
assertTrue(dataSettings.getStubSettings().getTracerFactory() instanceof MetricsApiTracerAdapterFactory);
}
use of com.google.cloud.bigtable.hbase.wrappers.veneer.metrics.MetricsApiTracerAdapterFactory in project java-bigtable-hbase by googleapis.
the class BigtableHBaseVeneerSettings method configureMetricsBridge.
private void configureMetricsBridge(Builder settings) {
MetricsApiTracerAdapterFactory metricsApiTracerAdapterFactory = new MetricsApiTracerAdapterFactory();
settings.stubSettings().setTracerFactory(metricsApiTracerAdapterFactory);
}
Aggregations