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]: 91cbde67c5/cli/command/telemetry.go (L62-L64)
[DockerCli.TracerProvider]: 91cbde67c5/cli/command/telemetry.go (L58-L60)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-04-08 12:21:50 +02:00
parent 8f9c25e8b0
commit 74021c07a5
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 4 additions and 2 deletions

View File

@ -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),

View File

@ -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),