Skip to content

fix(lettuce): set span status for Redis command errors in [5.1.0, 6.0.0)#19075

Closed
YaoYingLong wants to merge 5 commits into
open-telemetry:mainfrom
YaoYingLong:feature/lettuce-5.1
Closed

fix(lettuce): set span status for Redis command errors in [5.1.0, 6.0.0)#19075
YaoYingLong wants to merge 5 commits into
open-telemetry:mainfrom
YaoYingLong:feature/lettuce-5.1

Conversation

@YaoYingLong

Copy link
Copy Markdown
Contributor

For Lettuce versions in range [5.1.0.RELEASE, 6.0.0.RELEASE):
Spans are created via OpenTelemetryTracing. Only an error tag is attached to spans when Redis commands fail, while the span status is never updated.

Copilot AI review requested due to automatic review settings June 25, 2026 08:14
@YaoYingLong YaoYingLong requested a review from a team as a code owner June 25, 2026 08:14

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

This PR fixes a bug in the Lettuce 5.1 library instrumentation where, for Lettuce versions in [5.1.0.RELEASE, 6.0.0.RELEASE), a failed Redis command attached an error tag to the span but never set the span status to ERROR. In that version range Lettuce calls tag("error", ...) and finish() directly (the start(RedisCommand)onComplete path that builds a LettuceResponse only exists in 6.0+), so the span status extractor never saw an error message. The fix captures the error tag value and, when no response was recorded, synthesizes a LettuceResponse at finish() time so the existing status extractor (LettuceTelemetryBuilder lines 81-89) marks the span as errored.

Changes:

  • In OpenTelemetryTracing, capture the error tag value into a new errorMessage field and use it in finish() to build a LettuceResponse when no response is present, ensuring StatusCode.ERROR is applied.
  • Add WRONG_TYPE_KEY/WRONG_TYPE_VALUE constants and testLpushWrongTypeCommandSetsSpanStatus tests across the sync, async, and reactive abstract test classes verifying the error status and attributes under both old and stable semconv.

Reviewed changes

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

Show a summary per file
File Description
OpenTelemetryTracing.java Adds errorMessage field, captures it from the error tag, and synthesizes a LettuceResponse in finish() so failed commands get an ERROR span status.
AbstractLettuceClientTest.java Adds shared WRONG_TYPE_KEY/WRONG_TYPE_VALUE constants used by the new error tests.
AbstractLettuceSyncClientTest.java Adds a sync test asserting LPUSH on a string key fails and sets the span error status/attributes.
AbstractLettuceAsyncClientTest.java Adds the equivalent async (RedisFuture) error-status test.
AbstractLettuceReactiveClientTest.java Adds the equivalent reactive (block()) error-status test.

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 5 out of 5 changed files in this pull request and generated no new comments.

@trask

trask commented Jun 25, 2026

Copy link
Copy Markdown
Member

@YaoYingLong do you still need this now that #19055 has landed? Starting from 3.0 (eta August), the Java agent instrumentation won't use the library instrumentation anymore.

@YaoYingLong

Copy link
Copy Markdown
Contributor Author

@YaoYingLong do you still need this now that #19055 has landed? Starting from 3.0 (eta August), the Java agent instrumentation won't use the library instrumentation anymore.

@trask I've validated on v3-preview that the problem is fixed, so this part can be removed.

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