Skip to content

Commit

Permalink
Merge pull request #5456 from laurazard/fix-defer-mp-shutdown
Browse files Browse the repository at this point in the history
telemetry: fix early meterprovider shutdown
  • Loading branch information
thaJeztah authored Sep 20, 2024
2 parents a5fb752 + 1355d7e commit 48cfe21
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {

mp := dockerCli.MeterProvider()
if mp, ok := mp.(command.MeterProvider); ok {
if err := mp.Shutdown(ctx); err != nil {
otel.Handle(err)
}
defer func() {
if err := mp.Shutdown(ctx); err != nil {
otel.Handle(err)
}
}()
} else {
fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed")
}
Expand Down

0 comments on commit 48cfe21

Please sign in to comment.