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

When serializing SpanModel, if there is any external modification of TAGS, it will lead to panic, add RLock before calling Send to prevent this error. #218

Merged
merged 1 commit into from
Apr 24, 2024
Merged
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
6 changes: 6 additions & 0 deletions span_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
if atomic.CompareAndSwapInt32(&s.mustCollect, 1, 0) {
s.Duration = time.Since(s.Timestamp)
if s.flushOnFinish {
s.mtx.RLock()
s.tracer.reporter.Send(s.SpanModel)
s.mtx.RUnlock()
}
}
}
Expand All @@ -89,13 +91,17 @@
if atomic.CompareAndSwapInt32(&s.mustCollect, 1, 0) {
s.Duration = d
if s.flushOnFinish {
s.mtx.RLock()

Check warning on line 94 in span_implementation.go

View check run for this annotation

Codecov / codecov/patch

span_implementation.go#L94

Added line #L94 was not covered by tests
s.tracer.reporter.Send(s.SpanModel)
s.mtx.RUnlock()

Check warning on line 96 in span_implementation.go

View check run for this annotation

Codecov / codecov/patch

span_implementation.go#L96

Added line #L96 was not covered by tests
}
}
}

func (s *spanImpl) Flush() {
if s.SpanModel.Debug || (s.SpanModel.Sampled != nil && *s.SpanModel.Sampled) {
s.mtx.RLock()
s.tracer.reporter.Send(s.SpanModel)
s.mtx.RUnlock()
}
}
Loading