File tree

2 files changed

+9
-0
lines changed

2 files changed

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

115+
Span getCurrentSpan() {
116+
return currentSpan;
117+
}
118+
115119
@Override
116120
public long executePartitionedUpdate(Statement stmt) {
117121
setActive(null);
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import io.opencensus.metrics.Metrics;
7777
import io.opencensus.trace.Annotation;
7878
import io.opencensus.trace.AttributeValue;
79+
import io.opencensus.trace.BlankSpan;
7980
import io.opencensus.trace.Span;
8081
import io.opencensus.trace.Status;
8182
import io.opencensus.trace.Tracer;
@@ -1463,11 +1464,15 @@ public void prepareReadWriteTransaction() {
14631464

14641465
private void keepAlive() {
14651466
markUsed();
1467+
final Span previousSpan = delegate.getCurrentSpan();
1468+
delegate.setCurrentSpan(BlankSpan.INSTANCE);
14661469
try (ResultSet resultSet =
14671470
delegate
14681471
.singleUse(TimestampBound.ofMaxStaleness(60, TimeUnit.SECONDS))
14691472
.executeQuery(Statement.newBuilder("SELECT 1").build())) {
14701473
resultSet.next();
1474+
} finally {
1475+
delegate.setCurrentSpan(previousSpan);
14711476
}
14721477
}
14731478

0 commit comments

Comments
 (0)