Skip to content

Commit

Permalink
Handle lettuce 5.1 db.namespace conditionally based on semconv opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Nov 10, 2024
1 parent 74d07f1 commit c07aa44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ public synchronized Tracer.Span tag(String key, String value) {
argsString = value;
return this;
}
if (key.equals("db.namespace") && SemconvStability.emitOldDatabaseSemconv()) {
key = "db.name";
} else if (key.equals("db.name") && SemconvStability.emitStableDatabaseSemconv()) {
key = "db.namespace";
}
if (span != null) {
span.setAttribute(key, value);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.instrumentation.lettuce.v5_1;

import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_NAMESPACE;

Expand Down Expand Up @@ -83,7 +84,7 @@ private ContainerConnection(StatefulRedisConnection<String, String> connection,
protected static List<AttributeAssertion> addExtraAttributes(AttributeAssertion... assertions) {
List<AttributeAssertion> result = new ArrayList<>(Arrays.asList(assertions));
if (Boolean.getBoolean("testLatestDeps")) {
result.add(equalTo(DB_NAMESPACE, "0"));
result.add(equalTo(maybeStable(DB_NAMESPACE), "0"));
}
return result;
}
Expand Down

0 comments on commit c07aa44

Please sign in to comment.