Skip to content

feat(server-utils): Port Bedrock aws-sdk extension and add integration tests#22166

Draft
andreiborza wants to merge 2 commits into
ab/aws-sdk-serverlessfrom
ab/aws-sdk-bedrock
Draft

feat(server-utils): Port Bedrock aws-sdk extension and add integration tests#22166
andreiborza wants to merge 2 commits into
ab/aws-sdk-serverlessfrom
ab/aws-sdk-bedrock

Conversation

@andreiborza

@andreiborza andreiborza commented Jul 9, 2026

Copy link
Copy Markdown
Member

Ports the BedrockRuntime gen_ai service extension from the OTel aws-sdk integration to the orchestrion channel integration: chat span name and request parameters for Converse/ConverseStream, per-model-family request body parsing for InvokeModel/InvokeModelWithResponseStream (titan, nova, claude, llama, cohere, mistral), token usage and finish reasons from responses, and deferred span end for the streaming commands (the span ends when the wrapped stream is consumed).

Adds nock-mocked integration tests for the non-streaming Converse and InvokeModel commands, asserted against both the OTel and diagnostics-channel paths. The streaming commands use the AWS binary eventstream framing which nock cannot mock, so they stay untested here.

This completes orchestrion parity with the OTel aws-sdk integration.

User-facing differences to the vendored OTel instrumentation

  • ConverseStream callers receive the original response object with its stream wrapped in place, instead of a new object (a channel subscriber can't replace the resolved value); relevant only to identity-sensitive code

Fixes #20946

}

if (request.commandInput?.body) {
const requestBody = JSON.parse(request.commandInput.body);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

InvokeModel body not decoded

Medium Severity

_requestPreSpanHookInvokeModel passes commandInput.body directly to JSON.parse. The AWS SDK often supplies body as a Uint8Array (or Buffer), not a string; unlike the response path, the request path does not decode binary first, so parsing fails or request gen_ai attributes are missing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cccdbe5. Configure here.

@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from bdc838e to 9297436 Compare July 9, 2026 21:35
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch 2 times, most recently from 188ac82 to ff165d4 Compare July 9, 2026 21:44
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from 9297436 to 31816fd Compare July 9, 2026 21:44
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from ff165d4 to a4dd353 Compare July 9, 2026 21:48
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from 31816fd to 0b89e37 Compare July 9, 2026 21:48
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.34 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.13 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.62 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.26 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.32 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.61 kB - -
@sentry/vue 33.02 kB - -
@sentry/vue (incl. Tracing) 48.31 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.32 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB - -
CDN Bundle (incl. Tracing, Replay) 85.84 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.92 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.1 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.07 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.78 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.26 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.95 kB - -
@sentry/nextjs (client) 51.16 kB - -
@sentry/sveltekit (client) 46.78 kB - -
@sentry/core/server 78.43 kB - -
@sentry/core/browser 64.76 kB - -
@sentry/node-core 62.72 kB -0.01% -1 B 🔽
@sentry/node 125.37 kB - -
⛔️ @sentry/node (incl. diagnostics channel injection) (max: 142 kB) 143.3 kB +3.43% +4.75 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.72 kB - -
@sentry/node - without tracing 74.06 kB - -
@sentry/aws-serverless 83.25 kB - -
@sentry/cloudflare (withSentry) - minified 181.71 kB - -
@sentry/cloudflare (withSentry) 449.16 kB - -

View base workflow run

@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from a4dd353 to 968db2f Compare July 9, 2026 22:11
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from 0b89e37 to a3978fa Compare July 9, 2026 22:11
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from 968db2f to 5f2a15f Compare July 9, 2026 22:14
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch 2 times, most recently from 809da29 to 8907ff9 Compare July 9, 2026 22:31
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from 5f2a15f to 8f3599b Compare July 9, 2026 22:31

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f3599b. Configure here.

}
}

function recordCohereRAttributes(parsedChunk: any, span: Span): void {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Undocumented any in bedrock

Low Severity

New production code uses any for streamed chunk parsing and model-specific record helpers (and an index signature on ConverseStreamOutput) without comments explaining why stricter typing is not used, which the SDK review rules require for each any occurrence.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 8f3599b. Configure here.

@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from 8907ff9 to c0e10d6 Compare July 9, 2026 22:46
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from 8f3599b to 0a944ab Compare July 9, 2026 22:46
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from c0e10d6 to 561e41b Compare July 9, 2026 22:55
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from 0a944ab to 5506257 Compare July 9, 2026 22:55
andreiborza and others added 2 commits July 10, 2026 01:01
…n tests

Ports the BedrockRuntime gen_ai service extension from the OTel aws-sdk
integration to the orchestrion channel integration: chat span name and request
parameters for `Converse`/`ConverseStream`, per-model-family request body
parsing for `InvokeModel`/`InvokeModelWithResponseStream` (titan, nova, claude,
llama, cohere, mistral), token usage and finish reasons from responses, and
deferred span end for the streaming commands (the span ends when the wrapped
stream is consumed).

Adds nock-mocked integration tests for the non-streaming `Converse` and
`InvokeModel` commands, asserted against both the OTel and diagnostics-channel
paths. The streaming commands use the AWS binary eventstream framing which nock
cannot mock, so they stay untested here.

This completes orchestrion parity with the OTel aws-sdk integration.

Fixes #20946

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@andreiborza andreiborza force-pushed the ab/aws-sdk-serverless branch from 561e41b to 8ffb46b Compare July 9, 2026 23:02
@andreiborza andreiborza force-pushed the ab/aws-sdk-bedrock branch from 5506257 to 14699e8 Compare July 9, 2026 23:02
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.

Rewrite @opentelemetry/instrumentation-aws-sdk to orchestrion

1 participant