fix(lettuce): set span status for Redis command errors in [5.1.0, 6.0.0)#19075
fix(lettuce): set span status for Redis command errors in [5.1.0, 6.0.0)#19075YaoYingLong wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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 theerrortag value into a newerrorMessagefield and use it infinish()to build aLettuceResponsewhen no response is present, ensuringStatusCode.ERRORis applied. - Add
WRONG_TYPE_KEY/WRONG_TYPE_VALUEconstants andtestLpushWrongTypeCommandSetsSpanStatustests 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. |
|
@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. |
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.