use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createSampleRowKeysCallable.
/**
* Creates a callable chain to handle SampleRowKeys RPcs. The chain will:
*
* <ul>
* <li>Convert a table id to a {@link com.google.bigtable.v2.SampleRowKeysRequest}.
* <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}.
* <li>Spool responses into a list.
* <li>Retry on failure.
* <li>Convert the responses into {@link KeyOffset}s.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() {
String methodName = "SampleRowKeys";
ServerStreamingCallable<SampleRowKeysRequest, SampleRowKeysResponse> base = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<SampleRowKeysRequest, SampleRowKeysResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getSampleRowKeysMethod()).setParamsExtractor(new RequestParamsExtractor<SampleRowKeysRequest>() {
@Override
public Map<String, String> extract(SampleRowKeysRequest sampleRowKeysRequest) {
return ImmutableMap.of("table_name", sampleRowKeysRequest.getTableName(), "app_profile_id", sampleRowKeysRequest.getAppProfileId());
}
}).build(), settings.sampleRowKeysSettings().getRetryableCodes());
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> spoolable = base.all();
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withStatsHeaders = new StatsHeadersUnaryCallable<>(spoolable);
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> retryable = Callables.retrying(withHeaderTracer, settings.sampleRowKeysSettings(), clientContext);
return createUserFacingUnaryCallable(methodName, new SampleRowKeysCallable(retryable, requestContext));
}
Aggregations