Skip to content

Commit

Permalink
lock accesses to encoder
Browse files Browse the repository at this point in the history
fixes #2264
  • Loading branch information
lizthegrey committed Sep 28, 2021
1 parent 28f335e commit 79df6ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exporters/stdout/stdouttrace/trace.go
Expand Up @@ -49,6 +49,7 @@ func New(options ...Option) (*Exporter, error) {
// Exporter is an implementation of trace.SpanSyncer that writes spans to stdout.
type Exporter struct {
encoder *json.Encoder
encoderMu sync.Mutex
timestamps bool

stoppedMu sync.RWMutex
Expand Down Expand Up @@ -83,6 +84,8 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan)
}

// Encode span stubs, one by one
e.encoderMu.Lock()
defer e.encoderMu.Unlock()
if err := e.encoder.Encode(stub); err != nil {
return err
}
Expand Down

0 comments on commit 79df6ec

Please sign in to comment.