Update Jedis to stable database semconv#18808
Draft
trask wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.