From d90d8362acc96f4183a6924594ca2e67ab3b042d Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Thu, 7 Mar 2024 12:38:24 -0800 Subject: [PATCH] [exporter/loadbalancing] Do not block resolver by the exporter shutdown (#31602) This resolves the issues seen in https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31410 after merging https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/31456 --- exporter/loadbalancingexporter/loadbalancer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exporter/loadbalancingexporter/loadbalancer.go b/exporter/loadbalancingexporter/loadbalancer.go index a156ad9d9394..cccbc5c39245 100644 --- a/exporter/loadbalancingexporter/loadbalancer.go +++ b/exporter/loadbalancingexporter/loadbalancer.go @@ -148,7 +148,11 @@ func (lb *loadBalancer) removeExtraExporters(ctx context.Context, endpoints []st } for existing := range lb.exporters { if !endpointFound(existing, endpointsWithPort) { - _ = lb.exporters[existing].Shutdown(ctx) + exp := lb.exporters[existing] + // Shutdown the exporter asynchronously to avoid blocking the resolver + go func() { + _ = exp.Shutdown(ctx) + }() delete(lb.exporters, existing) } }