1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-20 03:30:02 +02:00

Flush metric events before shutdown in collector example (#1438)

Fixes #1437
This commit is contained in:
Tyler Yahn 2021-01-06 10:50:58 -08:00 committed by GitHub
parent f6f458e155
commit db06c8d1cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,9 +88,12 @@ func initProvider() func() {
pusher.Start()
return func() {
handleErr(tracerProvider.Shutdown(ctx), "failed to shutdown provider")
// Shutdown will flush any remaining spans.
handleErr(tracerProvider.Shutdown(ctx), "failed to shutdown TracerProvider")
// Push any last metric events to the exporter.
pusher.Stop()
handleErr(exp.Shutdown(ctx), "failed to stop exporter")
pusher.Stop() // pushes any last exports to the receiver
}
}