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 22, 2021
1 parent 26e3dc7 commit a995cd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -112,6 +112,10 @@ void setCurrentSpan(Span span) {
currentSpan = span;
}

Span getCurrentSpan() {
return currentSpan;
}

@Override
public long executePartitionedUpdate(Statement stmt) {
setActive(null);
Expand Down
Expand Up @@ -76,6 +76,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 @@ -1463,11 +1464,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 a995cd9

Please sign in to comment.