Skip to content

Skip ClassCastException on every DynamoDB request in AWS SDK v2 instrumentation#11285

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits intomasterfrom
dougqh/aws-sdk-v2-skip-dynamodb-cce
May 8, 2026
Merged

Skip ClassCastException on every DynamoDB request in AWS SDK v2 instrumentation#11285
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits intomasterfrom
dougqh/aws-sdk-v2-skip-dynamodb-cce

Conversation

@dougqh
Copy link
Copy Markdown
Contributor

@dougqh dougqh commented May 5, 2026

Summary

  • AwsSdkClientDecorator.onSdkRequest called getValueForField("Key", String.class) for every AWS SDK v2 request and silently caught a ClassCastException on every DynamoDB Get/Put/Update/Delete item call (DynamoDB models Key as Map<String, AttributeValue>).
  • The CCE was already noted in the original code's comment (// 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.
  • Gate Key extraction to S3 — the only AWS service whose top-level Key field is a String — and inline the helper so the dead try/catch goes away.
  • Behavior unchanged: setObjectKey writes the same aws.object.key tag the DSM-only branch was writing; the DSM branch is preserved for http.request.content_length only.

Test plan

  • CI green on :dd-java-agent:instrumentation:aws-java:aws-java-sdk-2.2:test (existing S3 GetObject/PutObject cases assert aws.object.key is set).
  • CI green on :dd-java-agent:instrumentation:aws-java:aws-java-dynamodb-2.0:test (verifies no regression on DynamoDB span tagging).
  • Spot-check a Localstack DynamoDB GetItem trace to confirm spans are unchanged.

🤖 Generated with Claude Code

…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>
@dougqh dougqh added inst: aws sdk AWS SDK instrumentation tag: ai generated Largely based on code generated by an AI or LLM tag: performance Performance related changes type: bug Bug report and fix labels May 5, 2026
@dougqh dougqh requested a review from ValentinZakharov May 5, 2026 20:21
@dougqh dougqh marked this pull request as ready for review May 6, 2026 19:20
@dougqh dougqh requested a review from a team as a code owner May 6, 2026 19:20
Copy link
Copy Markdown
Contributor

@ValentinZakharov ValentinZakharov left a comment

Choose a reason for hiding this comment

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

LGTM

@ValentinZakharov ValentinZakharov added this pull request to the merge queue May 8, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 8, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 8, 2026

View all feedbacks in Devflow UI.

2026-05-08 09:49:47 UTC ℹ️ Start processing command /merge


2026-05-08 09:49:51 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-08 11:02:13 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 8, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 0015e8c into master May 8, 2026
571 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/aws-sdk-v2-skip-dynamodb-cce branch May 8, 2026 11:02
@github-actions github-actions Bot added this to the 1.63.0 milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: aws sdk AWS SDK instrumentation tag: ai generated Largely based on code generated by an AI or LLM tag: performance Performance related changes type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants