-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Move onFinishCallback before span or transaction is finished #3459
Changes from all commits
757fbba
e08b9fe
021d752
1010eab
17b127d
123cc87
1b6faec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,9 @@ public final class Span implements ISpan { | |
|
||
private final @NotNull IHub hub; | ||
|
||
private final @NotNull AtomicBoolean finished = new AtomicBoolean(false); | ||
private boolean finished = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep |
||
|
||
private final @NotNull AtomicBoolean isFinishing = new AtomicBoolean(false); | ||
|
||
private final @NotNull SpanOptions options; | ||
|
||
|
@@ -122,7 +124,7 @@ public Span( | |
final @Nullable SentryDate timestamp, | ||
final @NotNull Instrumenter instrumenter, | ||
@NotNull SpanOptions spanOptions) { | ||
if (finished.get()) { | ||
if (finished) { | ||
return NoOpSpan.getInstance(); | ||
} | ||
|
||
|
@@ -133,7 +135,7 @@ public Span( | |
@Override | ||
public @NotNull ISpan startChild( | ||
final @NotNull String operation, final @Nullable String description) { | ||
if (finished.get()) { | ||
if (finished) { | ||
return NoOpSpan.getInstance(); | ||
} | ||
|
||
|
@@ -143,7 +145,7 @@ public Span( | |
@Override | ||
public @NotNull ISpan startChild( | ||
@NotNull String operation, @Nullable String description, @NotNull SpanOptions spanOptions) { | ||
if (finished.get()) { | ||
if (finished) { | ||
return NoOpSpan.getInstance(); | ||
} | ||
return transaction.startChild(context.getSpanId(), operation, description, spanOptions); | ||
|
@@ -192,7 +194,7 @@ public void finish(@Nullable SpanStatus status) { | |
@Override | ||
public void finish(final @Nullable SpanStatus status, final @Nullable SentryDate timestamp) { | ||
// the span can be finished only once | ||
if (!finished.compareAndSet(false, true)) { | ||
if (finished || !isFinishing.compareAndSet(false, true)) { | ||
return; | ||
} | ||
|
||
|
@@ -235,6 +237,7 @@ public void finish(final @Nullable SpanStatus status, final @Nullable SentryDate | |
if (spanFinishedCallback != null) { | ||
spanFinishedCallback.execute(this); | ||
} | ||
finished = true; | ||
} | ||
|
||
@Override | ||
|
@@ -284,7 +287,7 @@ public void setTag(final @NotNull String key, final @NotNull String value) { | |
|
||
@Override | ||
public boolean isFinished() { | ||
return finished.get(); | ||
return finished; | ||
} | ||
|
||
public @NotNull Map<String, Object> getData() { | ||
|
@@ -409,6 +412,11 @@ void setSpanFinishedCallback(final @Nullable SpanFinishedCallback callback) { | |
this.spanFinishedCallback = callback; | ||
} | ||
|
||
@Nullable | ||
SpanFinishedCallback getSpanFinishedCallback() { | ||
return spanFinishedCallback; | ||
} | ||
|
||
private void updateStartDate(@NotNull SentryDate date) { | ||
this.startTimestamp = date; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the performanceCollectors here, to fix an issue with
SpanFrameMetricsCollection
which was not setting the frame counts measurements, due to transaction being already finished