3535import static com .google .cloud .datastore .telemetry .TraceUtil .SPAN_NAME_TRANSACTION_LOOKUP ;
3636import static com .google .cloud .datastore .telemetry .TraceUtil .SPAN_NAME_TRANSACTION_RUN ;
3737import static com .google .cloud .datastore .telemetry .TraceUtil .SPAN_NAME_TRANSACTION_RUN_QUERY ;
38+ import static com .google .cloud .datastore .RequestOptionsHelper .createRequestOptions ;
3839
3940import com .google .api .core .BetaApi ;
4041import com .google .api .gax .retrying .ResultRetryAlgorithm ;
@@ -111,7 +112,7 @@ final class DatastoreImpl extends BaseService<DatastoreOptions> implements Datas
111112 private static final ExceptionHandler TRANSACTION_OPERATION_EXCEPTION_HANDLER =
112113 TransactionOperationExceptionHandler .build ();
113114
114- private final com . google . cloud . datastore . telemetry . TraceUtil otelTraceUtil =
115+ private final TraceUtil otelTraceUtil =
115116 getOptions ().getTraceUtil ();
116117 private final DatastoreMetricsRecorder metricsRecorder ;
117118 private final OpenTelemetry builtInOpenTelemetry ;
@@ -180,7 +181,7 @@ static class TracedReadWriteTransactionCallable<T> implements Callable<T> {
180181
181182 TracedReadWriteTransactionCallable (
182183 ReadWriteTransactionCallable <T > delegate ,
183- @ Nullable com . google . cloud . datastore . telemetry . TraceUtil .Span parentSpan ) {
184+ @ Nullable TraceUtil .Span parentSpan ) {
184185 this .delegate = delegate ;
185186 this .parentSpan = parentSpan ;
186187 }
@@ -435,7 +436,7 @@ RunQueryResponse runQuery(final RunQueryRequest requestPb) {
435436 return runWithObservability (
436437 () -> {
437438 RunQueryResponse response = datastoreRpc .runQuery (requestPb );
438- com . google . cloud . datastore . telemetry . TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
439+ TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
439440 if (span != null ) {
440441 span .addEvent (
441442 spanName + " complete." ,
@@ -488,7 +489,6 @@ public List<Key> allocateId(IncompleteKey... keys) {
488489 @ Override
489490 @ BetaApi
490491 public List <Key > allocateId (List <IncompleteKey > keys , DatastoreExecutionOptions executionOptions ) {
491- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
492492 Preconditions .checkArgument (
493493 verifyIncompleteKeyType (keys ), "keys must be IncompleteKey instances" );
494494 if (keys .isEmpty ()) {
@@ -501,7 +501,7 @@ public List<Key> allocateId(List<IncompleteKey> keys, DatastoreExecutionOptions
501501 requestPb .setProjectId (getOptions ().getProjectId ());
502502 requestPb .setDatabaseId (getOptions ().getDatabaseId ());
503503 requestPb .setRequestOptions (
504- RequestOptionsHelper . createRequestOptions (getOptions (), executionOptions ));
504+ createRequestOptions (getOptions (), executionOptions ));
505505 AllocateIdsResponse responsePb = allocateIds (requestPb .build ());
506506 ImmutableList .Builder <Key > keyList = ImmutableList .builder ();
507507 for (com .google .datastore .v1 .Key keyPb : responsePb .getKeysList ()) {
@@ -546,7 +546,6 @@ public List<Entity> add(FullEntity<?>... entities) {
546546 @ Override
547547 @ BetaApi
548548 public List <Entity > add (List <FullEntity <?>> entities , DatastoreExecutionOptions executionOptions ) {
549- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
550549 if (entities .isEmpty ()) {
551550 return Collections .emptyList ();
552551 }
@@ -567,7 +566,7 @@ public List<Entity> add(List<FullEntity<?>> entities, DatastoreExecutionOptions
567566 }
568567 mutationsPb .add (Mutation .newBuilder ().setInsert (entity .toPb ()).build ());
569568 }
570- CommitResponse commitResponse = commitMutation (mutationsPb .build (), executionOptions );
569+ CommitResponse commitResponse = commitMutation (mutationsPb .build ());
571570 Iterator <MutationResult > mutationResults = commitResponse .getMutationResultsList ().iterator ();
572571 ImmutableList .Builder <Entity > responseBuilder = ImmutableList .builder ();
573572 for (FullEntity <?> entity : entities ) {
@@ -663,7 +662,7 @@ Iterator<Entity> get(
663662 requestPb .setProjectId (getOptions ().getProjectId ());
664663 requestPb .setDatabaseId (getOptions ().getDatabaseId ());
665664 requestPb .setRequestOptions (
666- RequestOptionsHelper . createRequestOptions (getOptions (), executionOptions ));
665+ createRequestOptions (getOptions (), executionOptions ));
667666 return new ResultsIterator (requestPb );
668667 }
669668
@@ -707,7 +706,7 @@ LookupResponse lookup(final LookupRequest requestPb) {
707706 return runWithObservability (
708707 () -> {
709708 LookupResponse response = datastoreRpc .lookup (requestPb );
710- com . google . cloud . datastore . telemetry . TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
709+ TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
711710 if (span != null ) {
712711 span .addEvent (
713712 spanName + " complete." ,
@@ -738,15 +737,14 @@ public List<Key> reserveIds(Key... keys) {
738737 @ Override
739738 @ BetaApi
740739 public List <Key > reserveIds (List <Key > keys , DatastoreExecutionOptions executionOptions ) {
741- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
742740 ReserveIdsRequest .Builder requestPb = ReserveIdsRequest .newBuilder ();
743741 for (Key key : keys ) {
744742 requestPb .addKeys (key .toPb ());
745743 }
746744 requestPb .setProjectId (getOptions ().getProjectId ());
747745 requestPb .setDatabaseId (getOptions ().getDatabaseId ());
748746 requestPb .setRequestOptions (
749- RequestOptionsHelper . createRequestOptions (getOptions (), executionOptions ));
747+ createRequestOptions (getOptions (), executionOptions ));
750748 ReserveIdsResponse responsePb = reserveIds (requestPb .build ());
751749 ImmutableList .Builder <Key > keyList = ImmutableList .builder ();
752750 if (responsePb .isInitialized ()) {
@@ -773,7 +771,6 @@ public void update(Entity... entities) {
773771 @ Override
774772 @ BetaApi
775773 public void update (List <Entity > entities , DatastoreExecutionOptions executionOptions ) {
776- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
777774 if (!entities .isEmpty ()) {
778775 ImmutableList .Builder <Mutation > mutationsPb = ImmutableList .builder ();
779776 Map <Key , Entity > dedupEntities = new LinkedHashMap <>();
@@ -783,7 +780,7 @@ public void update(List<Entity> entities, DatastoreExecutionOptions executionOpt
783780 for (Entity entity : dedupEntities .values ()) {
784781 mutationsPb .add (Mutation .newBuilder ().setUpdate (entity .toPb ()).build ());
785782 }
786- commitMutation (mutationsPb .build (), executionOptions );
783+ commitMutation (mutationsPb .build ());
787784 }
788785 }
789786
@@ -801,7 +798,6 @@ public List<Entity> put(FullEntity<?>... entities) {
801798 @ Override
802799 @ BetaApi
803800 public List <Entity > put (List <FullEntity <?>> entities , DatastoreExecutionOptions executionOptions ) {
804- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
805801 if (entities .isEmpty ()) {
806802 return Collections .emptyList ();
807803 }
@@ -819,7 +815,7 @@ public List<Entity> put(List<FullEntity<?>> entities, DatastoreExecutionOptions
819815 for (Entity entity : dedupEntities .values ()) {
820816 mutationsPb .add (Mutation .newBuilder ().setUpsert (entity .toPb ()).build ());
821817 }
822- CommitResponse commitResponse = commitMutation (mutationsPb .build (), executionOptions );
818+ CommitResponse commitResponse = commitMutation (mutationsPb .build ());
823819 Iterator <MutationResult > mutationResults = commitResponse .getMutationResultsList ().iterator ();
824820 ImmutableList .Builder <Entity > responseBuilder = ImmutableList .builder ();
825821 for (FullEntity <?> entity : entities ) {
@@ -842,14 +838,13 @@ public void delete(Key... keys) {
842838 @ Override
843839 @ BetaApi
844840 public void delete (List <Key > keys , DatastoreExecutionOptions executionOptions ) {
845- Preconditions .checkNotNull (executionOptions , "executionOptions cannot be null" );
846841 if (!keys .isEmpty ()) {
847842 ImmutableList .Builder <Mutation > mutationsPb = ImmutableList .builder ();
848843 Set <Key > dedupKeys = new LinkedHashSet <>(keys );
849844 for (Key key : dedupKeys ) {
850845 mutationsPb .add (Mutation .newBuilder ().setDelete (key .toPb ()).build ());
851846 }
852- commitMutation (mutationsPb .build (), executionOptions );
847+ commitMutation (mutationsPb .build ());
853848 }
854849 }
855850
@@ -859,19 +854,14 @@ public KeyFactory newKeyFactory() {
859854 }
860855
861856 private CommitResponse commitMutation (ImmutableList <Mutation > mutationsPb ) {
862- return commitMutation (mutationsPb , DatastoreExecutionOptions .getDefaultInstance ());
863- }
864-
865- private CommitResponse commitMutation (
866- ImmutableList <Mutation > mutationsPb , DatastoreExecutionOptions executionOptions ) {
867857 CommitRequest .Builder requestPb =
868858 CommitRequest .newBuilder ()
869859 .setMode (CommitRequest .Mode .NON_TRANSACTIONAL )
870860 .setProjectId (getOptions ().getProjectId ())
871861 .setDatabaseId (getOptions ().getDatabaseId ())
872862 .addAllMutations (mutationsPb );
873863 requestPb .setRequestOptions (
874- RequestOptionsHelper . createRequestOptions (getOptions (), executionOptions ));
864+ createRequestOptions (getOptions (), null ));
875865 return commit (requestPb .build ());
876866 }
877867
@@ -883,7 +873,7 @@ CommitResponse commit(final CommitRequest requestPb) {
883873 return runWithObservability (
884874 () -> {
885875 CommitResponse response = datastoreRpc .commit (requestPb );
886- com . google . cloud . datastore . telemetry . TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
876+ TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
887877 if (span != null ) {
888878 span .addEvent (
889879 spanName + " complete." ,
@@ -917,24 +907,20 @@ BeginTransactionResponse beginTransaction(final BeginTransactionRequest requestP
917907 }
918908
919909 void rollbackTransaction (ByteString transaction ) {
920- rollbackTransaction (transaction , DatastoreExecutionOptions .getDefaultInstance ());
921- }
922-
923- void rollbackTransaction (ByteString transaction , DatastoreExecutionOptions executionOptions ) {
924910 RollbackRequest .Builder requestPb = RollbackRequest .newBuilder ();
925911 requestPb .setTransaction (transaction );
926912 requestPb .setProjectId (getOptions ().getProjectId ());
927913 requestPb .setDatabaseId (getOptions ().getDatabaseId ());
928914 requestPb .setRequestOptions (
929- RequestOptionsHelper . createRequestOptions (getOptions (), executionOptions ));
915+ createRequestOptions (getOptions (), null ));
930916 rollback (requestPb .build ());
931917 }
932918
933919 void rollback (final RollbackRequest requestPb ) {
934920 runWithObservability (
935921 () -> {
936922 datastoreRpc .rollback (requestPb );
937- com . google . cloud . datastore . telemetry . TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
923+ TraceUtil .Span span = otelTraceUtil .getCurrentSpan ();
938924 if (span != null ) {
939925 span .addEvent (
940926 SPAN_NAME_ROLLBACK ,
@@ -954,7 +940,7 @@ private <T> T runWithObservability(
954940 String methodName ,
955941 String spanName ,
956942 ResultRetryAlgorithm <?> exceptionHandler ) {
957- com . google . cloud . datastore . telemetry . TraceUtil .Span span = otelTraceUtil .startSpan (spanName );
943+ TraceUtil .Span span = otelTraceUtil .startSpan (spanName );
958944
959945 Stopwatch operationStopwatch = Stopwatch .createStarted ();
960946 String operationStatus = StatusCode .Code .OK .toString ();
0 commit comments