Skip to content

Commit

Permalink
otlptracegrpc: Shutdown returns context error (#3990)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
pellared and MrAlias authored Apr 13, 2023
1 parent b24bcc1 commit eb2b89f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion exporters/otlp/otlptrace/otlptracegrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ var errAlreadyStopped = errors.New("the client is already stopped")
// If the client has already stopped, an error will be returned describing
// this.
func (c *client) Stop(ctx context.Context) error {
// Make sure to return context error if the context is done when calling this method.
err := ctx.Err()

// Acquire the c.tscMu lock within the ctx lifetime.
acquired := make(chan struct{})
go func() {
c.tscMu.Lock()
close(acquired)
}()
var err error

select {
case <-ctx.Done():
// The Stop timeout is reached. Kill any remaining exports to force
Expand Down

0 comments on commit eb2b89f

Please sign in to comment.