Skip to content

Commit

Permalink
fix: blanks span for session keepAlive traces (#797)
Browse files Browse the repository at this point in the history
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 1a86e4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -113,6 +113,10 @@ void setCurrentSpan(Span span) {
currentSpan = span;
}

Span getCurrentSpan() {
return currentSpan;
}

@Override
public long executePartitionedUpdate(Statement stmt, UpdateOption... options) {
setActive(null);
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1a86e4f

Please sign in to comment.