Skip to content

Commit 34c47d4

Browse files
POTEL 34 - Retrieve the correct current span from Scope/Scopes (#3554)
* Use parent span id from sentry-trace header * attach active span to scope * record dropped span/transaction in SentrySampler * changelog * record lost span when copying parent decision * Format code * refactor: use sampling decision * Retrieve current span from scope(s) in span factory * changelog --------- Co-authored-by: Sentry Github Bot <[email protected]>
1 parent a31a59e commit 34c47d4

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Attach active span to scope when using OpenTelemetry ([#3549](https://github.com/getsentry/sentry-java/pull/3549))
1111
- Errors weren't linked to traces correctly due to parts of the SDK not knowing the current span
1212
- Record dropped spans in client report when sampling out OpenTelemetry spans ([#3552](https://github.com/getsentry/sentry-java/pull/3552))
13+
- Retrieve the correct current span from `Scope`/`Scopes` when using OpenTelemetry ([#3554](https://github.com/getsentry/sentry-java/pull/3554))
1314

1415
## 8.0.0-alpha.3
1516

sentry-opentelemetry/sentry-opentelemetry-extra/src/main/java/io/sentry/opentelemetry/OtelSpanFactory.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,16 @@ public final class OtelSpanFactory implements ISpanFactory {
152152
return sentrySpan;
153153
}
154154

155+
// TODO [POTEL] consider removing this method
155156
@Override
156157
public @Nullable ISpan retrieveCurrentSpan(IScopes scopes) {
157-
final @Nullable Span span = Span.fromContextOrNull(Context.current());
158-
if (span == null) {
159-
return null;
160-
}
161-
return storage.getSentrySpan(span.getSpanContext());
158+
return scopes.getSpan();
162159
}
163160

161+
// TODO [POTEL] consider removing this method
164162
@Override
165163
public @Nullable ISpan retrieveCurrentSpan(IScope scope) {
166-
final @Nullable Span span = Span.fromContextOrNull(Context.current());
167-
if (span == null) {
168-
return null;
169-
}
170-
return storage.getSentrySpan(span.getSpanContext());
164+
return scope.getSpan();
171165
}
172166

173167
private @NotNull Tracer getTracer() {

0 commit comments

Comments
 (0)