Skip to content

Commit

Permalink
Access clients under a lock
Browse files Browse the repository at this point in the history
The client may change as a result on reconnection in background, so
guard against a racy access.
  • Loading branch information
krnowak committed Dec 2, 2020
1 parent 3a2ee0b commit 2f9aaa0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions exporters/otlp/grpcsingle.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,28 @@ type grpcSingleConnectionDriver struct {
}

func (d *grpcSingleConnectionDriver) getMetricsClient() grpcMetricsClient {
d.lock.Lock()
client := d.metricsClient
d.lock.Unlock()
return grpcMetricsClient{
grpcClientBase: grpcClientBase{
clientLock: &d.lock,
connection: d.connection,
},
client: d.metricsClient,
client: client,
}
}

func (d *grpcSingleConnectionDriver) getTracesClient() grpcTracesClient {
d.lock.Lock()
client := d.tracesClient
d.lock.Unlock()
return grpcTracesClient{
grpcClientBase: grpcClientBase{
clientLock: &d.lock,
connection: d.connection,
},
client: d.tracesClient,
client: client,
}
}

Expand Down

0 comments on commit 2f9aaa0

Please sign in to comment.