Skip ClassCastException on every DynamoDB request in AWS SDK v2 instrumentation#11285
Draft
Skip ClassCastException on every DynamoDB request in AWS SDK v2 instrumentation#11285
Conversation
…orator
`getValueForField("Key", String.class)` was called on every AWS SDK v2
request and a `ClassCastException` was caught on every DynamoDB
Get/Put/Update/Delete item call (Key is `Map<String, AttributeValue>`).
This forced the JVM to fill in a stack trace per request on a hot path.
Gate the `Key` extraction to S3 (the only service whose top-level `Key`
is a `String`), inline the helper, and drop the dead try/catch. Behavior
for S3 is unchanged — `setObjectKey` already wrote the same tag the
DSM-only branch was writing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
AwsSdkClientDecorator.onSdkRequestcalledgetValueForField("Key", String.class)for every AWS SDK v2 request and silently caught aClassCastExceptionon every DynamoDB Get/Put/Update/Delete item call (DynamoDB modelsKeyasMap<String, AttributeValue>).// Key is not always a string, like for dynamodb GetItemRequest), but the JVM still filled in a stack trace per request on a hot path.Keyextraction to S3 — the only AWS service whose top-levelKeyfield is aString— and inline the helper so the deadtry/catchgoes away.setObjectKeywrites the sameaws.object.keytag the DSM-only branch was writing; the DSM branch is preserved forhttp.request.content_lengthonly.Test plan
:dd-java-agent:instrumentation:aws-java:aws-java-sdk-2.2:test(existing S3 GetObject/PutObject cases assertaws.object.keyis set).:dd-java-agent:instrumentation:aws-java:aws-java-dynamodb-2.0:test(verifies no regression on DynamoDB span tagging).🤖 Generated with Claude Code