From 74021c07a53b5f14b8c250b84f01d19716eb2a9a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 8 Apr 2025 12:21:50 +0200 Subject: [PATCH] command: runBuild, runBake: remove uses of DockerCLI.MeterProvider The [DockerCli.MeterProvider] (and [DockerCli.TracerProvider]) methods have no direct connection with the CLI itself and are wrappers for `otel.GetMeterProvider()` and `otel.GetTracerProvider()`. Remove the use of the CLI method, and use the otel functions directly. [DockerCli.MeterProvider]: https://github.com/docker/cli/blob/91cbde67c509c8702417ee1cd64cd5d845ccd254/cli/command/telemetry.go#L62-L64 [DockerCli.TracerProvider]: https://github.com/docker/cli/blob/91cbde67c509c8702417ee1cd64cd5d845ccd254/cli/command/telemetry.go#L58-L60 Signed-off-by: Sebastiaan van Stijn --- commands/bake.go | 3 ++- commands/build.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/bake.go b/commands/bake.go index dea0faba6b2c..12f99373990e 100644 --- a/commands/bake.go +++ b/commands/bake.go @@ -38,6 +38,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/tonistiigi/go-csvvalue" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" ) @@ -64,7 +65,7 @@ type bakeOptions struct { } func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in bakeOptions, cFlags commonFlags) (err error) { - mp := dockerCli.MeterProvider() + mp := otel.GetMeterProvider() ctx, end, err := tracing.TraceCurrentCommand(ctx, append([]string{"bake"}, targets...), attribute.String("builder", in.builder), diff --git a/commands/build.go b/commands/build.go index 9c3ae2802992..d0acbdd6dd9e 100644 --- a/commands/build.go +++ b/commands/build.go @@ -59,6 +59,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/tonistiigi/go-csvvalue" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "google.golang.org/grpc/codes" @@ -284,7 +285,7 @@ func (o *buildOptionsHash) String() string { } func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) (err error) { - mp := dockerCli.MeterProvider() + mp := otel.GetMeterProvider() ctx, end, err := tracing.TraceCurrentCommand(ctx, []string{"build", options.contextPath}, attribute.String("builder", options.builder),