File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ void setCurrentSpan(Span span) {
113113
currentSpan = span;
114114
}
115115

116+
Span getCurrentSpan() {
117+
return currentSpan;
118+
}
119+
116120
@Override
117121
public long executePartitionedUpdate(Statement stmt, UpdateOption... options) {
118122
setActive(null);
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import io.opencensus.metrics.Metrics;
7878
import io.opencensus.trace.Annotation;
7979
import io.opencensus.trace.AttributeValue;
80+
import io.opencensus.trace.BlankSpan;
8081
import io.opencensus.trace.Span;
8182
import io.opencensus.trace.Status;
8283
import io.opencensus.trace.Tracer;
@@ -1472,11 +1473,15 @@ public void prepareReadWriteTransaction() {
14721473

14731474
private void keepAlive() {
14741475
markUsed();
1476+
final Span previousSpan = delegate.getCurrentSpan();
1477+
delegate.setCurrentSpan(BlankSpan.INSTANCE);
14751478
try (ResultSet resultSet =
14761479
delegate
14771480
.singleUse(TimestampBound.ofMaxStaleness(60, TimeUnit.SECONDS))
14781481
.executeQuery(Statement.newBuilder("SELECT 1").build())) {
14791482
resultSet.next();
1483+
} finally {
1484+
delegate.setCurrentSpan(previousSpan);
14801485
}
14811486
}
14821487

0 commit comments

Comments
 (0)