Skip to content

Commit

Permalink
Flush metric events before shutdown in collector example (#1438)
Browse files Browse the repository at this point in the history
Fixes #1437
  • Loading branch information
MrAlias authored Jan 6, 2021
1 parent f6f458e commit db06c8d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions example/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit db06c8d

Please sign in to comment.