fix opentelemetry

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2024-05-23 11:02:18 +02:00 committed by Guillaume Lours
parent 2593256985
commit 7ad73c2899
3 changed files with 5 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import (
"github.com/docker/compose/v2/internal/tracing" "github.com/docker/compose/v2/internal/tracing"
"github.com/spf13/cobra" "github.com/spf13/cobra"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace"
@ -50,7 +51,7 @@ func Setup(cmd *cobra.Command, dockerCli command.Cli, args []string) error {
} }
ctx := cmd.Context() ctx := cmd.Context()
ctx, cmdSpan := tracing.Tracer.Start( ctx, cmdSpan := otel.Tracer("").Start(
ctx, ctx,
"cli/"+strings.Join(commandName(cmd), "-"), "cli/"+strings.Join(commandName(cmd), "-"),
) )

View File

@ -46,8 +46,6 @@ func init() {
otel.SetErrorHandler(skipErrors{}) otel.SetErrorHandler(skipErrors{})
} }
var Tracer = otel.Tracer("compose")
// OTLPConfig contains the necessary values to initialize an OTLP client // OTLPConfig contains the necessary values to initialize an OTLP client
// manually. // manually.
// //

View File

@ -20,6 +20,7 @@ import (
"context" "context"
"github.com/acarl005/stripansi" "github.com/acarl005/stripansi"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.19.0" semconv "go.opentelemetry.io/otel/semconv/v1.19.0"
@ -36,7 +37,7 @@ import (
// adding even more levels of function wrapping/indirection. // adding even more levels of function wrapping/indirection.
func SpanWrapFunc(spanName string, opts SpanOptions, fn func(ctx context.Context) error) func(context.Context) error { func SpanWrapFunc(spanName string, opts SpanOptions, fn func(ctx context.Context) error) func(context.Context) error {
return func(ctx context.Context) error { return func(ctx context.Context) error {
ctx, span := Tracer.Start(ctx, spanName, opts.SpanStartOptions()...) ctx, span := otel.Tracer("").Start(ctx, spanName, opts.SpanStartOptions()...)
defer span.End() defer span.End()
if err := fn(ctx); err != nil { if err := fn(ctx); err != nil {
@ -59,7 +60,7 @@ func SpanWrapFunc(spanName string, opts SpanOptions, fn func(ctx context.Context
// adding even more levels of function wrapping/indirection. // adding even more levels of function wrapping/indirection.
func SpanWrapFuncForErrGroup(ctx context.Context, spanName string, opts SpanOptions, fn func(ctx context.Context) error) func() error { func SpanWrapFuncForErrGroup(ctx context.Context, spanName string, opts SpanOptions, fn func(ctx context.Context) error) func() error {
return func() error { return func() error {
ctx, span := Tracer.Start(ctx, spanName, opts.SpanStartOptions()...) ctx, span := otel.Tracer("").Start(ctx, spanName, opts.SpanStartOptions()...)
defer span.End() defer span.End()
if err := fn(ctx); err != nil { if err := fn(ctx); err != nil {