Skip to content

Update Jedis to stable database semconv#18808

Merged
trask merged 15 commits into
mainfrom
trask/jedis-db-namespace
Jun 10, 2026
Merged

Update Jedis to stable database semconv#18808
trask merged 15 commits into
mainfrom
trask/jedis-db-namespace

Conversation

@trask

@trask trask commented May 20, 2026

Copy link
Copy Markdown
Member

Update the Jedis 4.0 javaagent instrumentation to fill in the remaining stable database semantic convention fields that require connection metadata:

  • db.namespace from the configured Redis database index
  • server.address
  • server.port

This also updates stable database span names to include the server endpoint fallback and adds the Jedis connection metadata plumbing needed to capture those values for command spans.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

trask added 3 commits June 6, 2026 14:21
CI compiled the Jedis 4 javaagent against a Jedis version where
JedisClientConfig#getDatabase returns Integer, while the captured database
index is stored as Long. Convert the returned database index with
Long.valueOf(...) so the source compiles against both int and Integer
signatures.

Validation: .\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:compileJava
Validation: .\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:compileJava -PtestLatestDeps=true
Validation: .\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:muzzle
Validation: .\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:muzzle -PtestLatestDeps=true
Jedis 4 stable semconv tests expected db.namespace on spans and
metrics from the default connection, but stable Redis telemetry only
emits db.namespace when the Jedis client is explicitly configured with
a database index. Update the span assertions and duration metric
expectation to match the emitted attributes.

Validation:
.\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:testStableSemconv
.\gradlew.bat :instrumentation:jedis:jedis-4.0:javaagent:testStableSemconv -PtestLatestDeps=true

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@trask
trask marked this pull request as ready for review June 8, 2026 04:27
@trask
trask requested a review from a team as a code owner June 8, 2026 04:27
trask added 2 commits June 9, 2026 18:09
…space

# Conflicts:
#	instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java
#	instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java
#	instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java
Instrumenter.<JedisRequest, Void>builder(
GlobalOpenTelemetry.get(),
INSTRUMENTATION_NAME,
DbClientSpanNameExtractor.create(dbAttributesGetter))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not really necessary since namespace is not implemented

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

GlobalOpenTelemetry.get(),
INSTRUMENTATION_NAME,
DbClientSpanNameExtractor.create(dbAttributesGetter))
request -> spanName(dbAttributesGetter, request))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wondering maybe it would be better to use something like

    JedisDbAttributesGetter spanNameAttributesGetter = new JedisDbAttributesGetter() {
      @Override
      @Nullable
      public String getDbNamespace(JedisRequest request) {
        return null;
      }
    };
...
DbClientSpanNameExtractor.create(spanNameAttributesGetter))

so that the whole name logic wouldn't need to be reimplemented.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@trask
trask enabled auto-merge (squash) June 10, 2026 13:58
@trask
trask merged commit 724f581 into main Jun 10, 2026
182 of 186 checks passed
@trask
trask deleted the trask/jedis-db-namespace branch June 10, 2026 14:10
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.

3 participants