|
30 | 30 | import java.util.Collection;
|
31 | 31 | import java.util.LinkedHashSet;
|
32 | 32 | import java.util.List;
|
| 33 | +import java.util.Optional; |
33 | 34 | import java.util.Queue;
|
34 | 35 | import java.util.Set;
|
35 | 36 | import java.util.concurrent.atomic.AtomicLong;
|
36 | 37 |
|
37 | 38 | import io.lettuce.core.ClientOptions;
|
| 39 | +import io.lettuce.core.ConnectionBuilder; |
38 | 40 | import io.lettuce.core.RedisConnectionException;
|
| 41 | +import io.lettuce.core.RedisCredentials; |
39 | 42 | import io.lettuce.core.RedisException;
|
| 43 | +import io.lettuce.core.RedisURI; |
40 | 44 | import io.lettuce.core.api.push.PushListener;
|
41 | 45 | import io.lettuce.core.api.push.PushMessage;
|
42 | 46 | import io.lettuce.core.internal.LettuceAssert;
|
@@ -478,6 +482,15 @@ private void attachTracing(ChannelHandlerContext ctx, RedisCommand<?, ?, ?> comm
|
478 | 482 | Tracer.Span span = tracer.nextSpan(context);
|
479 | 483 | span.name(command.getType().toString());
|
480 | 484 |
|
| 485 | + if (channel.hasAttr(ConnectionBuilder.REDIS_URI)) { |
| 486 | + String redisUriStr = channel.attr(ConnectionBuilder.REDIS_URI).get(); |
| 487 | + RedisURI redisURI = RedisURI.create(redisUriStr); |
| 488 | + span.tag("server.address", redisURI.toString()); |
| 489 | + span.tag("db.namespace", String.valueOf(redisURI.getDatabase())); |
| 490 | + span.tag("user.name", Optional.ofNullable(redisURI.getCredentialsProvider().resolveCredentials().block()) |
| 491 | + .map(RedisCredentials::getUsername).orElse("")); |
| 492 | + } |
| 493 | + |
481 | 494 | if (tracedEndpoint != null) {
|
482 | 495 | span.remoteEndpoint(tracedEndpoint);
|
483 | 496 | } else {
|
|
0 commit comments