Skip to content

Commit

Permalink
chore(recorder): Simplify Reset method in SpanRecorder for better…
Browse files Browse the repository at this point in the history
… concurrency safety
  • Loading branch information
flc1125 committed Nov 22, 2024
1 parent 9004454 commit 7f07b60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- Add concurrent-safe `Reset` method to `SpanRecorder` in `go.opentelemetry.io/otel/sdk/trace/tracetest`. (#5994)
- Add `Reset` method to `SpanRecorder` in `go.opentelemetry.io/otel/sdk/trace/tracetest`. (#5994)

### Changed

Expand Down
8 changes: 4 additions & 4 deletions sdk/trace/tracetest/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ func (sr *SpanRecorder) Started() []sdktrace.ReadWriteSpan {
// This method is safe to be called concurrently.
func (sr *SpanRecorder) Reset() {
sr.startedMu.Lock()
sr.started = nil
sr.startedMu.Unlock()

sr.endedMu.Lock()
defer sr.startedMu.Unlock()
defer sr.endedMu.Unlock()

sr.started = nil
sr.ended = nil
sr.endedMu.Unlock()
}

// Ended returns a copy of all ended spans that have been recorded.
Expand Down

0 comments on commit 7f07b60

Please sign in to comment.