Skip to content

Commit d0be67f

Browse files
authored
Prevent Lettuce Redis db.namespace being included in span names (#18984)
1 parent 0094958 commit d0be67f

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class JedisSingletons {
2828

2929
static {
3030
JedisDbAttributesGetter dbAttributesGetter = new JedisDbAttributesGetter();
31+
// Redis semantic conventions don't follow the regular pattern of adding db.namespace to the
32+
// span name.
3133
JedisDbAttributesGetter spanNameAttributesGetter =
3234
new JedisDbAttributesGetter() {
3335
@Override

instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceDbAttributesGetter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.net.InetSocketAddress;
1010
import javax.annotation.Nullable;
1111

12-
final class LettuceDbAttributesGetter
12+
class LettuceDbAttributesGetter
1313
implements DbClientAttributesGetter<LettuceRequest, LettuceResponse> {
1414

1515
// copied from DbIncubatingAttributes.DbSystemIncubatingValues

instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceTelemetryBuilder.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
1919
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
2020
import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor;
21+
import javax.annotation.Nullable;
2122

2223
/** A builder of {@link LettuceTelemetry}. */
2324
public final class LettuceTelemetryBuilder {
@@ -59,12 +60,22 @@ public LettuceTelemetryBuilder setEncodingSpanEventsEnabled(boolean encodingEven
5960
*/
6061
public LettuceTelemetry build() {
6162
LettuceDbAttributesGetter dbAttributesGetter = new LettuceDbAttributesGetter();
63+
// Redis semantic conventions don't follow the regular pattern of adding db.namespace to the
64+
// span name.
65+
LettuceDbAttributesGetter spanNameAttributesGetter =
66+
new LettuceDbAttributesGetter() {
67+
@Override
68+
@Nullable
69+
public String getDbNamespace(LettuceRequest request) {
70+
return null;
71+
}
72+
};
6273

6374
InstrumenterBuilder<LettuceRequest, LettuceResponse> builder =
6475
Instrumenter.<LettuceRequest, LettuceResponse>builder(
6576
openTelemetry,
6677
INSTRUMENTATION_NAME,
67-
DbClientSpanNameExtractor.create(dbAttributesGetter))
78+
DbClientSpanNameExtractor.create(spanNameAttributesGetter))
6879
.addAttributesExtractor(DbClientAttributesExtractor.create(dbAttributesGetter))
6980
.addOperationMetrics(DbClientMetrics.get())
7081
.setSpanStatusExtractor(

0 commit comments

Comments
 (0)