diff --git a/src/main/java/io/lettuce/core/protocol/CommandHandler.java b/src/main/java/io/lettuce/core/protocol/CommandHandler.java index cf9f12e80c..b6864a57ae 100644 --- a/src/main/java/io/lettuce/core/protocol/CommandHandler.java +++ b/src/main/java/io/lettuce/core/protocol/CommandHandler.java @@ -466,21 +466,26 @@ private void attachTracing(ChannelHandlerContext ctx, RedisCommand comm TracedCommand traced = CommandWrapper.unwrap(command, TracedCommand.class); TraceContextProvider provider = (traced == null ? clientResources.tracing().initialTraceContextProvider() : traced); Tracer tracer = clientResources.tracing().getTracerProvider().getTracer(); - TraceContext context = provider.getTraceContext(); - Tracer.Span span = tracer.nextSpan(context); - span.name(command.getType().name()); + if (provider != null) { - if (tracedEndpoint != null) { - span.remoteEndpoint(tracedEndpoint); - } else { - span.remoteEndpoint(clientResources.tracing().createEndpoint(ctx.channel().remoteAddress())); - } + TraceContext context = provider.getTraceContext(); + + Tracer.Span span = tracer.nextSpan(context); + span.name(command.getType().name()); + + if (tracedEndpoint != null) { + span.remoteEndpoint(tracedEndpoint); + } else { + span.remoteEndpoint(clientResources.tracing().createEndpoint(ctx.channel().remoteAddress())); + } - span.start(command); + span.start(command); - if (traced != null) { - traced.setSpan(span); + if (traced != null) { + traced.setSpan(span); + + } } }