Skip to content
Permalink
Browse files
fix: blanks span for session keepAlive traces (#797)
The keepAlive traces were being tracked along with the parent span set
by the client, which clutters the tracing stack. Here, we set the
tracing to blank before issueing the keepAlive query.
  • Loading branch information
thiagotnunes committed Jan 14, 2021
1 parent 90255ea commit 1a86e4fd5b6198c300c13eba4d3d9d91c12c43f7
@@ -113,6 +113,10 @@ void setCurrentSpan(Span span) {
currentSpan = span;
}

Span getCurrentSpan() {
return currentSpan;
}

@Override
public long executePartitionedUpdate(Statement stmt, UpdateOption... options) {
setActive(null);
@@ -77,6 +77,7 @@
import io.opencensus.metrics.Metrics;
import io.opencensus.trace.Annotation;
import io.opencensus.trace.AttributeValue;
import io.opencensus.trace.BlankSpan;
import io.opencensus.trace.Span;
import io.opencensus.trace.Status;
import io.opencensus.trace.Tracer;
@@ -1472,11 +1473,15 @@ public void prepareReadWriteTransaction() {

private void keepAlive() {
markUsed();
final Span previousSpan = delegate.getCurrentSpan();
delegate.setCurrentSpan(BlankSpan.INSTANCE);
try (ResultSet resultSet =
delegate
.singleUse(TimestampBound.ofMaxStaleness(60, TimeUnit.SECONDS))
.executeQuery(Statement.newBuilder("SELECT 1").build())) {
resultSet.next();
} finally {
delegate.setCurrentSpan(previousSpan);
}
}

0 comments on commit 1a86e4f

Please sign in to comment.