Merge pull request #5457 from laurazard/backport-dropped-defer

[27.x backport] telemetry: fix early meterprovider shutdown
This commit is contained in:
Laura Brehm 2024-09-20 01:49:45 +01:00 committed by GitHub
commit f05200311d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -360,9 +360,11 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
mp := dockerCli.MeterProvider()
if mp, ok := mp.(command.MeterProvider); ok {
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")
}