Skip to content

Commit

Permalink
fix opentelemetry
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof authored and glours committed May 23, 2024
1 parent 2593256 commit 7ad73c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/cmdtrace/cmd_span.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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), "-"),
)
Expand Down
2 changes: 0 additions & 2 deletions internal/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
5 changes: 3 additions & 2 deletions internal/tracing/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 7ad73c2

Please sign in to comment.