Skip to content

feat(bedrock): Add extension skeleton - #8226

Draft
alexander-alderman-webb wants to merge 1 commit into
masterfrom
webb/bedrock/skeleton
Draft

alexander-alderman-webb wants to merge 1 commit into
masterfrom
webb/bedrock/skeleton

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Add a basic bedrock extension that sets the gen_ai.operation.name, gen_ai.provider.name and gen_ai.response.streaming attributes.

This is the first boto3 extension. I've cleaned up some things:

  • Remove registry.py. We control all extensions in the SDK, so this indirection seems unnecessary.
  • Related to the above, remove tests for the registry system that define mock extensions. Create success and error test cases in test_bedrock.py so the relevant behavior is still exercised.
  • Remove capture_internal_exceptions() around invocations of extension functions. If there's code that can raise in the extensions, the extensions can wrap the relevant lines themselves.
  • Add a skip_if_no_active_span boolean so that Bedrock spans are created even when there is no active span, matching the behavior of other chat integrations.

@alexander-alderman-webb
alexander-alderman-webb force-pushed the webb/bedrock/skeleton branch 4 times, most recently from 819486b to 3fc87ab Compare November 9, 2026 09:37
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review November 9, 2026 09:41
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner November 9, 2026 09:41
Comment on lines +51 to +54
(span,) = (item.payload for item in items if item.type == "span")

assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "aws.bedrock"
assert span["attributes"][SPANDATA.GEN_AI_RESPONSE_STREAMING] is False

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.

Bedrock tests assume streaming span payloads in static mode

All four tests run with span_streaming=False, but still search for standalone type == "span" items and read span attributes from span["attributes"]. Static mode stores child spans in the transaction payload under spans and their attributes under data, so those cases fail. The error tests also need to accept the static span status internal_error in addition to error.

Evidence
  • Each Bedrock test parametrizes span_streaming as True and False, but always selects a standalone span item and reads attributes.
  • _capture_boto3_spans_by_op in test_client.py handles static mode by reading transaction["spans"]; _span_attributes reads static attributes from data.
  • _finish_span sets static spans with an exception to internal_error, while the Bedrock error tests assert only error.

Identified by Warden · code-review · RSS-AQT

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

right this magic works because of stream_gen_ai_spans.
I'll create equivalent tests for when the option is disabled.

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.

Fix attempt detected (commit d6cde74)

The tests explicitly parameterize static mode, but still read standalone span attributes and assert only the streaming-mode error status, so the reported failures remain.

The original issue appears unresolved. Please review and try again.

Evaluated by Warden

@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.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 136504 passed | ❌ 1 failed | ⏭️ 7521 skipped | Total: 144026 | Pass Rate: 94.78% | Execution Time: 444m 54s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -651
Passed Tests 📉 -717
Failed Tests 📈 +1
Skipped Tests 📈 +65

➕ New Tests (1)

View new tests
  • test_cache_spans_templatetag[True]
    • File: tests.integrations.django.test_cache_module
    • Status: ❌ Failing

❌ Failed Tests

test_cache_spans_templatetag[True]

File: tests.integrations.django.test_cache_module
Suite: py3.14-django-v5.2.18
Error: tests/integrations/django/test_cache_module.py:485: in test_cache_spans_templatetag assert not spans[0]["attributes"]["cache.hit"] E assert not True

Stack Trace
tests/integrations/django/test_cache_module.py:485: in test_cache_spans_templatetag
    assert not spans[0]["attributes"]["cache.hit"]
E   assert not True

✅ Patch coverage is 91.18% (31 of 34 changed executable lines covered; target 80%).
Project statement coverage is 90.28% (down 0.02 percentage points from base (d565fed) to head (3fc87ab)).

Changed files with executable lines (4)
File Patch coverage Changed executable lines
sentry_sdk/integrations/boto3/_services/bedrock.py 85.00% 17/20 covered; missed: 19, 24, 29; partial branches: 18, 23, 28
sentry_sdk/integrations/boto3/_instrumentation.py 100.00% 9/9 covered; partial branches: 185, 189, 195
sentry_sdk/integrations/boto3/_client.py 100.00% 4/4 covered
sentry_sdk/integrations/boto3/_services/base.py 100.00% 1/1 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8226       +/-##
==========================================
- Coverage    90.30%    90.28%    -0.02%
==========================================
  Files          203       203         —
  Tracked lines     26933     26946       +13
  Branches     10058     10064        +6
==========================================
+ Hits         24321     24328        +7
- Misses        2612      2618        +6
- Partials      1518      1521        +3

Generated by Coverage Action

@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 1 potential issue.

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 d6cde74. Configure here.

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as draft November 9, 2026 09:54

This branch has not been deployed

No deployments
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.

1 participant