Skip to content

fix: remove unused DmlBatch span #3147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ B setSpan(@Nullable Span span) {
this.span = Preconditions.checkNotNull(builder.span);
}

@Override
public Span getSpan() {
return this.span;
}

ApiFuture<Void> asyncEndUnitOfWorkSpan() {
return this.statementExecutor.submit(this::endUnitOfWorkSpan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class ConnectionImpl implements Connection {
private static final String SINGLE_USE_TRANSACTION = "SingleUseTransaction";
private static final String READ_ONLY_TRANSACTION = "ReadOnlyTransaction";
private static final String READ_WRITE_TRANSACTION = "ReadWriteTransaction";
private static final String DML_BATCH = "DmlBatch";
private static final String DDL_BATCH = "DdlBatch";
private static final String DDL_STATEMENT = "DdlStatement";

Expand Down Expand Up @@ -1932,7 +1931,8 @@ UnitOfWork createNewUnitOfWork(
.setStatementTag(statementTag)
.setExcludeTxnFromChangeStreams(excludeTxnFromChangeStreams)
.setRpcPriority(rpcPriority)
.setSpan(createSpanForUnitOfWork(DML_BATCH))
// Use the transaction Span for the DML batch.
.setSpan(transactionStack.peek().getSpan())
.build();
case DDL_BATCH:
return DdlBatch.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.cloud.spanner.TransactionContext;
import com.google.cloud.spanner.connection.AbstractStatementParser.ParsedStatement;
import com.google.spanner.v1.ResultSetStats;
import io.opentelemetry.api.trace.Span;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;

Expand Down Expand Up @@ -77,6 +78,9 @@ public boolean isActive() {
/** @return <code>true</code> if this unit of work is still active. */
boolean isActive();

/** @return the {@link Span} that is used by this {@link UnitOfWork}. */
Span getSpan();

/** Returns true if this transaction can only be used for a single statement. */
boolean isSingleUse();

Expand Down
Loading