Skip to content

Commit

Permalink
Change to use non-deprecated function
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Christensen <kimworking@gmail.com>
  • Loading branch information
kichristensen committed May 5, 2024
1 parent 25b32d8 commit 19ceea9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/portercontext/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand All @@ -47,7 +47,7 @@ func (c *Context) configureTelemetry(ctx context.Context, cfg LogConfiguration,
}

func createNoopTracer() tracing.Tracer {
tracer := trace.NewNoopTracerProvider().Tracer("noop")
tracer := noop.NewTracerProvider().Tracer("noop")
cleanup := func(_ context.Context) error { return nil }
t := tracing.NewTracer(tracer, cleanup)
t.IsNoOp = true
Expand Down
4 changes: 2 additions & 2 deletions pkg/tracing/traceLogger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
)

func TestTraceLogger_ShouldLog(t *testing.T) {
logger := zaptest.NewLogger(t, zaptest.Level(zap.WarnLevel))
tracer := trace.NewNoopTracerProvider().Tracer("noop")
tracer := noop.NewTracerProvider().Tracer("noop")
l := newTraceLogger(context.Background(), nil, logger, NewTracer(tracer, nil))

assert.True(t, l.ShouldLog(zap.ErrorLevel))
Expand Down
3 changes: 2 additions & 1 deletion pkg/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand Down Expand Up @@ -34,7 +35,7 @@ func LoggerFromContext(ctx context.Context) TraceLogger {
} else {
// default to no-op
logger = zap.NewNop()
tracer = trace.NewNoopTracerProvider().Tracer("noop")
tracer = noop.NewTracerProvider().Tracer("noop")
}

return newTraceLogger(ctx, span, logger, NewTracer(tracer, nil))
Expand Down

0 comments on commit 19ceea9

Please sign in to comment.