Skip to content

Commit

Permalink
telemetry: fix early meterprovider shutdown
Browse files Browse the repository at this point in the history
In 4b5a196, we changed the CLI global
meter provider shutdown in order to handle any error returned by the
metric export.

Unfortunately, we dropped a `defer` during the fix, which
causes the meter provider to be immediately shutdown after being created
and metrics to not be collected/exporter.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit 1355d7e)
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
  • Loading branch information
laurazard committed Sep 20, 2024
1 parent e85edf8 commit 460f1be
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 @@ -360,9 +360,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 460f1be

Please sign in to comment.