Search in sources :

Example 1 with OpencensusTracerFactory

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();
}
Also used : InstantiatingGrpcChannelProvider(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider) CompositeTracerFactory(com.google.cloud.bigtable.data.v2.stub.metrics.CompositeTracerFactory) TagKey(io.opencensus.tags.TagKey) TagValue(io.opencensus.tags.TagValue) OpencensusTracerFactory(com.google.api.gax.tracing.OpencensusTracerFactory) ServiceAccountJwtAccessCredentials(com.google.auth.oauth2.ServiceAccountJwtAccessCredentials) Credentials(com.google.auth.Credentials)

Aggregations

InstantiatingGrpcChannelProvider (com.google.api.gax.grpc.InstantiatingGrpcChannelProvider)1 OpencensusTracerFactory (com.google.api.gax.tracing.OpencensusTracerFactory)1 Credentials (com.google.auth.Credentials)1 ServiceAccountJwtAccessCredentials (com.google.auth.oauth2.ServiceAccountJwtAccessCredentials)1 CompositeTracerFactory (com.google.cloud.bigtable.data.v2.stub.metrics.CompositeTracerFactory)1 TagKey (io.opencensus.tags.TagKey)1 TagValue (io.opencensus.tags.TagValue)1