Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit f752b0c

Browse files
authored
In debug builds, assert() that End() isn't called more than once. (#82)
Followup to: #70
1 parent 5bc9592 commit f752b0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

opencensus/trace/internal/span.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ void Span::SetStatus(StatusCode canonical_code, absl::string_view message) {
201201
}
202202

203203
void Span::End() {
204-
if (IsRecording() && !span_impl_->HasEnded()) {
204+
if (IsRecording()) {
205+
if (span_impl_->HasEnded()) {
206+
assert(false && "Invalid attempt to End() the same Span more than once.");
207+
// In non-debug builds, ignore the second End().
208+
return;
209+
}
205210
span_impl_->End();
206211
exporter::RunningSpanStoreImpl::Get()->RemoveSpan(span_impl_);
207212
exporter::LocalSpanStoreImpl::Get()->AddSpan(span_impl_);

0 commit comments

Comments
 (0)