use of io.lettuce.core.tracing.TraceContextProvider in project lettuce-core by lettuce-io.
the class CommandHandler method attachTracing.
private void attachTracing(ChannelHandlerContext ctx, RedisCommand<?, ?, ?> command) {
if (!tracingEnabled || !(command instanceof CompleteableCommand)) {
return;
}
TracedCommand<?, ?, ?> traced = CommandWrapper.unwrap(command, TracedCommand.class);
TraceContextProvider provider = (traced == null ? clientResources.tracing().initialTraceContextProvider() : traced);
Tracer tracer = clientResources.tracing().getTracerProvider().getTracer();
if (provider != null) {
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);
if (traced != null) {
traced.setSpan(span);
}
}
}
use of io.lettuce.core.tracing.TraceContextProvider in project lettuce-core by lettuce-io.
the class RedisChannelHandler method dispatch.
protected Collection<RedisCommand<K, V, ?>> dispatch(Collection<? extends RedisCommand<K, V, ?>> commands) {
if (debugEnabled) {
logger.debug("dispatching commands {}", commands);
}
if (tracingEnabled) {
Collection<RedisCommand<K, V, ?>> withTracer = new ArrayList<>(commands.size());
for (RedisCommand<K, V, ?> command : commands) {
RedisCommand<K, V, ?> commandToUse = command;
TraceContextProvider provider = CommandWrapper.unwrap(command, TraceContextProvider.class);
if (provider == null) {
commandToUse = new TracedCommand<>(command, clientResources.tracing().initialTraceContextProvider().getTraceContext());
}
withTracer.add(commandToUse);
}
return channelWriter.write(withTracer);
}
return channelWriter.write(commands);
}
use of io.lettuce.core.tracing.TraceContextProvider in project lettuce-core by lettuce-io.
the class RedisChannelHandler method dispatch.
protected <T> RedisCommand<K, V, T> dispatch(RedisCommand<K, V, T> cmd) {
if (debugEnabled) {
logger.debug("dispatching command {}", cmd);
}
if (tracingEnabled) {
RedisCommand<K, V, T> commandToSend = cmd;
TraceContextProvider provider = CommandWrapper.unwrap(cmd, TraceContextProvider.class);
if (provider == null) {
commandToSend = new TracedCommand<>(cmd, clientResources.tracing().initialTraceContextProvider().getTraceContext());
}
return channelWriter.write(commandToSend);
}
return channelWriter.write(cmd);
}
Aggregations