use of com.google.api.gax.tracing.OpencensusTracerFactory in project java-bigtable by googleapis.
the class EnhancedBigtableStub method finalizeSettings.
public static EnhancedBigtableStubSettings finalizeSettings(EnhancedBigtableStubSettings settings, Tagger tagger, StatsRecorder stats) throws IOException {
EnhancedBigtableStubSettings.Builder builder = settings.toBuilder();
// TODO: this implementation is on the cusp of unwieldy, if we end up adding more features
// consider splitting it up by feature.
// workaround JWT audience issues
patchCredentials(builder);
// Inject channel priming
if (settings.isRefreshingChannel()) {
// Fix the credentials so that they can be shared
Credentials credentials = null;
if (settings.getCredentialsProvider() != null) {
credentials = settings.getCredentialsProvider().getCredentials();
}
builder.setCredentialsProvider(FixedCredentialsProvider.create(credentials));
// Inject the primer
InstantiatingGrpcChannelProvider transportProvider = (InstantiatingGrpcChannelProvider) settings.getTransportChannelProvider();
builder.setTransportChannelProvider(transportProvider.toBuilder().setChannelPrimer(BigtableChannelPrimer.create(credentials, settings.getProjectId(), settings.getInstanceId(), settings.getAppProfileId(), settings.getPrimedTableIds())).build());
}
ImmutableMap<TagKey, TagValue> attributes = ImmutableMap.<TagKey, TagValue>builder().put(RpcMeasureConstants.BIGTABLE_PROJECT_ID, TagValue.create(settings.getProjectId())).put(RpcMeasureConstants.BIGTABLE_INSTANCE_ID, TagValue.create(settings.getInstanceId())).put(RpcMeasureConstants.BIGTABLE_APP_PROFILE_ID, TagValue.create(settings.getAppProfileId())).build();
// Inject Opencensus instrumentation
builder.setTracerFactory(new CompositeTracerFactory(ImmutableList.of(// Add OpenCensus Tracing
new OpencensusTracerFactory(ImmutableMap.<String, String>builder().put(RpcMeasureConstants.BIGTABLE_PROJECT_ID.getName(), settings.getProjectId()).put(RpcMeasureConstants.BIGTABLE_INSTANCE_ID.getName(), settings.getInstanceId()).put(RpcMeasureConstants.BIGTABLE_APP_PROFILE_ID.getName(), settings.getAppProfileId()).put("gax", GaxGrpcProperties.getGaxGrpcVersion()).put("grpc", GaxGrpcProperties.getGrpcVersion()).put("gapic", Version.VERSION).build()), // Add OpenCensus Metrics
MetricsTracerFactory.create(tagger, stats, attributes), // Add user configured tracer
settings.getTracerFactory())));
return builder.build();
}
Aggregations