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

Only use parent span context if it's valid #383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.rpc.Code;
import com.google.rpc.Status;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.sdk.resources.Resource;
Expand Down Expand Up @@ -120,11 +121,14 @@ Span generateSpan(SpanData spanData, String projectId) {
spanBuilder.setEndTime(toTimestampProto(end));
}
spanBuilder.setLinks(toLinksProto(spanData.getLinks(), spanData.getTotalRecordedLinks()));
if (spanData.getParentSpanContext().isValid()) {
spanBuilder.setParentSpanId(spanData.getParentSpanId());

SpanContext parent = spanData.getParentSpanContext();
if (parent.isValid()) {
spanBuilder
.setParentSpanId(parent.getSpanId())
.setSameProcessAsParentSpan(BoolValue.of(!parent.isRemote()));
}
boolean hasRemoteParent = spanData.getParentSpanContext().isRemote();
spanBuilder.setSameProcessAsParentSpan(BoolValue.of(!hasRemoteParent));

return spanBuilder.build();
}

Expand Down
Loading