From d7dbd5eb964a97147466b4f43e8062f8d89f2b81 Mon Sep 17 00:00:00 2001 From: Kacper Stasik Date: Wed, 10 Feb 2021 17:07:45 +0100 Subject: [PATCH] fix: grpc reconnection fixed --- exporters/otlp/otlpgrpc/connection.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/exporters/otlp/otlpgrpc/connection.go b/exporters/otlp/otlpgrpc/connection.go index c469d099c3e..81dc095bf6a 100644 --- a/exporters/otlp/otlpgrpc/connection.go +++ b/exporters/otlp/otlpgrpc/connection.go @@ -135,21 +135,23 @@ func (c *connection) indefiniteBackgroundConnection() { // 1. If we've stopped, return entirely // 2. Otherwise block until we are disconnected, and // then retry connecting - select { - case <-c.stopCh: - return - - case <-c.disconnectedCh: - // Quickly check if we haven't stopped at the - // same time. + if c.connected() { select { case <-c.stopCh: return - default: - } + case <-c.disconnectedCh: + // Quickly check if we haven't stopped at the + // same time. + select { + case <-c.stopCh: + return + + default: + } - // Normal scenario that we'll wait for + // Normal scenario that we'll wait for + } } if err := c.connect(context.Background()); err == nil {