Skip to content

Update Jedis to stable database semconv#18808

Draft
trask wants to merge 1 commit into
mainfrom
trask/jedis-db-namespace
Draft

Update Jedis to stable database semconv#18808
trask wants to merge 1 commit into
mainfrom
trask/jedis-db-namespace

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented May 20, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Jedis instrumentations to align with stable database semantic conventions by enriching span attributes and span naming (primarily for Jedis 4.0), and adjusts tests to validate the new stable-semconv behavior.

Changes:

  • Jedis 4.0: capture server address/port + configured database index and emit them via stable semconv (including updated span naming).
  • Jedis 1.4/3.0: update span naming behavior under stable database semconv.
  • Tests: reset Redis DB to index 0 between tests and add/extend stable-semconv assertions.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
instrumentation/jedis/jedis-common-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/common/v1_4/JedisRequestContext.java Adds helper to derive a database index for stable semconv emission.
instrumentation/jedis/jedis-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/Jedis40ClientTest.java Updates assertions for stable DB semconv span names/attributes and adds db.namespace scenarios.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/redis/clients/jedis/DefaultJedisSocketFactoryUtil.java Injected helper to access Jedis package-private host/port from socket factory.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java Replaces generic DB span-name extractor with Redis-specific stable-semconv span naming; adds VirtualField for connection metadata.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisRequest.java Extends request model to carry server/db metadata needed for stable semconv.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisInstrumentationModule.java Enables injected helper class loading for Jedis 4.0 via experimental module hooks.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java Implements stable-semconv getters for db.namespace and server.* attributes.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisConnectionInstrumentation.java Captures connection metadata at construction and threads connection through request creation.
instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisConnectionInfo.java Stores extracted server address/port and configured database index for reuse per connection.
instrumentation/jedis/jedis-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/Jedis30ClientTest.java Ensures tests reset Redis DB index to 0 between runs.
instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java Updates span naming to match stable DB semconv behavior.
instrumentation/jedis/jedis-1.4/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/AbstractJedisTest.java Ensures tests reset Redis DB index to 0 between runs.
instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java Updates span naming to match stable DB semconv behavior.

Comment on lines 23 to 26
private static final Instrumenter<JedisRequest, Void> instrumenter;
private static final VirtualField<Connection, JedisConnectionInfo> connectionInfo =
VirtualField.find(Connection.class, JedisConnectionInfo.class);

Comment on lines +45 to +49
public static JedisConnectionInfo connectionInfo(Connection connection) {
return connectionInfo.get(connection);
}

public static void setConnectionInfo(
Comment on lines +39 to 50
public static JedisRequest create(
@Nullable Object connection, ProtocolCommand command, List<byte[]> args) {
JedisConnectionInfo connectionInfo = getConnectionInfo(connection);
return new AutoValue_JedisRequest(
command,
args,
connection,
connectionInfo != null ? connectionInfo.getServerAddress() : null,
connectionInfo != null ? connectionInfo.getServerPort() : null,
JedisRequestContext.databaseIndex(
connection, connectionInfo != null ? connectionInfo.getDatabaseIndex() : null));
}
Comment on lines +196 to +213
@Test
void selectCommandKeepsConnectionDatabaseIndex() {
jedis.select(1);
jedis.set("foo", "bar");

testing.waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(
emitStableDatabaseSemconv() ? "SELECT " + host + ":" + port : "SELECT")
.hasKind(SpanKind.CLIENT)
.hasAttributesSatisfyingExactly(
equalTo(maybeStable(DB_SYSTEM), REDIS),
equalTo(maybeStable(DB_STATEMENT), "SELECT 1"),
equalTo(maybeStable(DB_OPERATION), "SELECT"),
equalTo(DB_NAMESPACE, emitStableDatabaseSemconv() ? "0" : null),
equalTo(SERVER_ADDRESS, host),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants