Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blanks span for session keepAlive traces #797

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, instead of doing this, set the current span on the delegate to blank during close. I think that this is the least intrusive approach, that is why I went for it.

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