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

View File

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

View File

@ -20,6 +20,7 @@ import (
"context"
"github.com/acarl005/stripansi"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.19.0"
@ -36,7 +37,7 @@ import (
// adding even more levels of function wrapping/indirection.
func SpanWrapFunc(spanName string, opts SpanOptions, fn func(ctx context.Context) error) func(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()
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.
func SpanWrapFuncForErrGroup(ctx context.Context, spanName string, opts SpanOptions, fn func(ctx context.Context) error) 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()
if err := fn(ctx); err != nil {