Skip to content

Commit 649e564

Browse files
authored
Merge pull request #5444 from jsternberg/handle-otel-errors
telemetry: pass otel errors to the otel handler for shutdown and force flush
2 parents a4619f3 + b1956f5 commit 649e564

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cli/command/telemetry_utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/docker/cli/cli/version"
1010
"github.com/pkg/errors"
1111
"github.com/spf13/cobra"
12+
"go.opentelemetry.io/otel"
1213
"go.opentelemetry.io/otel/attribute"
1314
"go.opentelemetry.io/otel/metric"
1415
)
@@ -94,7 +95,9 @@ func startCobraCommandTimer(mp metric.MeterProvider, attrs []attribute.KeyValue)
9495
metric.WithAttributes(cmdStatusAttrs...),
9596
)
9697
if mp, ok := mp.(MeterProvider); ok {
97-
mp.ForceFlush(ctx)
98+
if err := mp.ForceFlush(ctx); err != nil {
99+
otel.Handle(err)
100+
}
98101
}
99102
}
100103
}

cmd/docker/docker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
358358

359359
mp := dockerCli.MeterProvider()
360360
if mp, ok := mp.(command.MeterProvider); ok {
361-
defer mp.Shutdown(ctx)
361+
if err := mp.Shutdown(ctx); err != nil {
362+
otel.Handle(err)
363+
}
362364
} else {
363365
fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed")
364366
}

0 commit comments

Comments
 (0)