use of com.google.api.gax.tracing.TracedOperationInitialCallable in project gax-java by googleapis.
the class GrpcCallableFactory method createOperationCallable.
/**
* Creates a callable object that represents a long-running operation. Designed for use by
* generated code.
*
* @param grpcCallSettings the gRPC call settings
* @param operationCallSettings {@link OperationCallSettings} to configure the method-level
* settings with.
* @param clientContext {@link ClientContext} to use to connect to the service.
* @param operationsStub {@link OperationsStub} to use to poll for updates on the Operation.
* @return {@link com.google.api.gax.rpc.OperationCallable} callable object.
*/
public static <RequestT, ResponseT, MetadataT> OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable(GrpcCallSettings<RequestT, Operation> grpcCallSettings, OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, ClientContext clientContext, OperationsStub operationsStub) {
SpanName initialSpanName = getSpanName(grpcCallSettings.getMethodDescriptor());
SpanName operationSpanName = SpanName.of(initialSpanName.getClientName(), initialSpanName.getMethodName() + "Operation");
UnaryCallable<RequestT, Operation> initialGrpcCallable = createBaseUnaryCallable(grpcCallSettings, operationCallSettings.getInitialCallSettings(), clientContext);
UnaryCallable<RequestT, OperationSnapshot> initialCallable = new GrpcOperationSnapshotCallable<>(initialGrpcCallable);
// Create a sub-trace for the initial RPC that starts the operation.
UnaryCallable<RequestT, OperationSnapshot> tracedInitialCallable = new TracedOperationInitialCallable<>(initialCallable, clientContext.getTracerFactory(), initialSpanName);
LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub);
OperationCallable<RequestT, ResponseT, MetadataT> operationCallable = Callables.longRunningOperation(tracedInitialCallable, operationCallSettings, clientContext, longRunningClient);
OperationCallable<RequestT, ResponseT, MetadataT> tracedOperationCallable = new TracedOperationCallable<>(operationCallable, clientContext.getTracerFactory(), operationSpanName);
return tracedOperationCallable.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Aggregations