File tree Expand file tree Collapse file tree
tracer/test/test-applications/integrations/Samples.OpenTelemetrySdk Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,12 +145,13 @@ public static async Task Main(string[] args)
145145 }
146146
147147#if OTEL_1_2
148- // Flush OTLP metric batches before Dispose. MeterProviderSdk.Dispose caps its shutdown
149- // call at 5s, but the first gRPC export (TCP+HTTP/2+TLS handshake) can exceed that and
150- // the OTel SDK's metric export timeout default is 30s. Force a flush on the critical
151- // path with the full export timeout instead of racing the 5s shutdown cap.
152- meterProvider ? . ForceFlush ( timeoutMilliseconds : 30_000 ) ;
153- meterProvider ? . Dispose ( ) ;
148+ // Shutdown with a generous timeout so the single final Collect+Export can complete even
149+ // when the first gRPC export has to negotiate TCP+HTTP/2+TLS. We avoid ForceFlush-then-
150+ // Dispose because two Collects on cumulative-temporality observable instruments re-emit
151+ // the same cumulative values and produce duplicate resource_metrics batches. Shutdown
152+ // performs exactly one Collect; the `using var` Dispose at end-of-scope no-ops via the
153+ // SDK's internal shutdown-count guard.
154+ meterProvider ? . Shutdown ( timeoutMilliseconds : 30_000 ) ;
154155#endif
155156#if OTEL_1_9
156157 // Flush OTLP log batches before the ServiceProvider's `using` disposes them.
You can’t perform that action at this time.
0 commit comments