Commit f7891c1 1 parent e00b884 commit f7891c1 Copy full SHA for f7891c1
File tree 3 files changed +11
-2
lines changed
google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,11 @@ B setSpan(@Nullable Span span) {
165
165
this .span = Preconditions .checkNotNull (builder .span );
166
166
}
167
167
168
+ @ Override
169
+ public Span getSpan () {
170
+ return this .span ;
171
+ }
172
+
168
173
ApiFuture <Void > asyncEndUnitOfWorkSpan () {
169
174
return this .statementExecutor .submit (this ::endUnitOfWorkSpan );
170
175
}
Original file line number Diff line number Diff line change @@ -96,7 +96,6 @@ class ConnectionImpl implements Connection {
96
96
private static final String SINGLE_USE_TRANSACTION = "SingleUseTransaction" ;
97
97
private static final String READ_ONLY_TRANSACTION = "ReadOnlyTransaction" ;
98
98
private static final String READ_WRITE_TRANSACTION = "ReadWriteTransaction" ;
99
- private static final String DML_BATCH = "DmlBatch" ;
100
99
private static final String DDL_BATCH = "DdlBatch" ;
101
100
private static final String DDL_STATEMENT = "DdlStatement" ;
102
101
@@ -1932,7 +1931,8 @@ UnitOfWork createNewUnitOfWork(
1932
1931
.setStatementTag (statementTag )
1933
1932
.setExcludeTxnFromChangeStreams (excludeTxnFromChangeStreams )
1934
1933
.setRpcPriority (rpcPriority )
1935
- .setSpan (createSpanForUnitOfWork (DML_BATCH ))
1934
+ // Use the transaction Span for the DML batch.
1935
+ .setSpan (transactionStack .peek ().getSpan ())
1936
1936
.build ();
1937
1937
case DDL_BATCH :
1938
1938
return DdlBatch .newBuilder ()
Original file line number Diff line number Diff line change 31
31
import com .google .cloud .spanner .TransactionContext ;
32
32
import com .google .cloud .spanner .connection .AbstractStatementParser .ParsedStatement ;
33
33
import com .google .spanner .v1 .ResultSetStats ;
34
+ import io .opentelemetry .api .trace .Span ;
34
35
import java .util .concurrent .ExecutionException ;
35
36
import javax .annotation .Nonnull ;
36
37
@@ -77,6 +78,9 @@ public boolean isActive() {
77
78
/** @return <code>true</code> if this unit of work is still active. */
78
79
boolean isActive ();
79
80
81
+ /** @return the {@link Span} that is used by this {@link UnitOfWork}. */
82
+ Span getSpan ();
83
+
80
84
/** Returns true if this transaction can only be used for a single statement. */
81
85
boolean isSingleUse ();
82
86
You can’t perform that action at this time.
0 commit comments