Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Fixes

- Removed user segment ([#3512](https://github.com/getsentry/sentry-java/pull/3512))
- Use span id of remote parent ([#3548](https://github.com/getsentry/sentry-java/pull/3548))
- Traces were broken because on an incoming request, OtelSentrySpanProcessor did not set the parentSpanId on the span correctly. Traces were not referencing the actual parent span but some other (random) span ID which the server doesn't know.

## 8.0.0-alpha.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ public void onStart(final @NotNull Context parentContext, final @NotNull ReadWri
TracesSamplingDecision samplingDecision =
OtelSamplingUtil.extractSamplingDecisionOrDefault(otelSpan.toSpanData().getAttributes());
@Nullable Baggage baggage = null;
@Nullable SpanId sentryParentSpanId = null;
otelSpan.setAttribute(IS_REMOTE_PARENT, otelSpan.getParentSpanContext().isRemote());
if (sentryParentSpan == null) {
final @NotNull String traceId = otelSpan.getSpanContext().getTraceId();
final @NotNull String spanId = otelSpan.getSpanContext().getSpanId();
final @NotNull SpanId sentrySpanId = new SpanId(spanId);
final @NotNull String parentSpanId = otelSpan.getParentSpanContext().getSpanId();
final @Nullable SpanId sentryParentSpanId =
sentryParentSpanId =
io.opentelemetry.api.trace.SpanId.isValid(parentSpanId) ? new SpanId(parentSpanId) : null;

@Nullable
Expand Down Expand Up @@ -99,7 +100,13 @@ public void onStart(final @NotNull Context parentContext, final @NotNull ReadWri
new SentryLongDate(otelSpan.toSpanData().getStartEpochNanos());
final @NotNull OtelSpanWrapper sentrySpan =
new OtelSpanWrapper(
otelSpan, scopes, startTimestamp, samplingDecision, sentryParentSpan, baggage);
otelSpan,
scopes,
startTimestamp,
samplingDecision,
sentryParentSpan,
sentryParentSpanId,
baggage);
sentrySpan.getSpanContext().setOrigin(SentrySpanExporter.TRACE_ORIGIN);
spanStorage.storeSentrySpan(spanContext, sentrySpan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public SamplingResult shouldSample(
.getOptions()
.getInternalTracesSampler()
.sample(new SamplingContext(transactionContext, null));
// TODO [POTEL] if sampling decision = false, we should record it in client report
return new SentrySamplingResult(sentryDecision);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public final class io/sentry/opentelemetry/OtelContextScopesStorage : io/sentry/
}

public final class io/sentry/opentelemetry/OtelSpanContext : io/sentry/SpanContext {
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/OtelSpanWrapper;Lio/sentry/Baggage;)V
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/OtelSpanWrapper;Lio/sentry/SpanId;Lio/sentry/Baggage;)V
public fun getOperation ()Ljava/lang/String;
public fun getStatus ()Lio/sentry/SpanStatus;
public fun setOperation (Ljava/lang/String;)V
Expand All @@ -27,7 +27,7 @@ public final class io/sentry/opentelemetry/OtelSpanFactory : io/sentry/ISpanFact
}

public final class io/sentry/opentelemetry/OtelSpanWrapper : io/sentry/ISpan {
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/IScopes;Lio/sentry/SentryDate;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/OtelSpanWrapper;Lio/sentry/Baggage;)V
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/IScopes;Lio/sentry/SentryDate;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/OtelSpanWrapper;Lio/sentry/SpanId;Lio/sentry/Baggage;)V
public fun finish ()V
public fun finish (Lio/sentry/SpanStatus;)V
public fun finish (Lio/sentry/SpanStatus;Lio/sentry/SentryDate;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public OtelSpanContext(
final @NotNull ReadWriteSpan span,
final @Nullable TracesSamplingDecision samplingDecision,
final @Nullable OtelSpanWrapper parentSpan,
final @Nullable SpanId parentSpanId,
final @Nullable Baggage baggage) {
super(
new SentryId(span.getSpanContext().getTraceId()),
new SpanId(span.getSpanContext().getSpanId()),
parentSpan == null ? null : parentSpan.getSpanContext().getSpanId(),
parentSpan == null ? parentSpanId : parentSpan.getSpanContext().getSpanId(),
span.getName(),
null,
samplingDecision != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public OtelSpanWrapper(
final @NotNull SentryDate startTimestamp,
final @Nullable TracesSamplingDecision samplingDecision,
final @Nullable OtelSpanWrapper parentSpan,
final @Nullable SpanId parentSpanId,
final @Nullable Baggage baggage) {
this.scopes = Objects.requireNonNull(scopes, "scopes are required");
this.span = new WeakReference<>(span);
Expand All @@ -101,7 +102,8 @@ public OtelSpanWrapper(
this.baggage = null;
}

this.context = new OtelSpanContext(span, samplingDecision, parentSpan, this.baggage);
this.context =
new OtelSpanContext(span, samplingDecision, parentSpan, parentSpanId, this.baggage);
}

@Override
Expand Down