Skip to content

feat(boto3): trace logical AWS calls with common attributes - #7481

Open
pabloDeputter wants to merge 34 commits into
masterfrom
pablo/improve-boto3-call-lifecycle
Open

pabloDeputter wants to merge 34 commits into
masterfrom
pablo/improve-boto3-call-lifecycle

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Sep 11, 2026

Copy link
Copy Markdown
Member

Description

Implements #7474 and #7475 by moving boto3 instrumentation from individual HTTP request attempts to botocore client-call lifecycle and adding some common OTel AWS attributes.

Previously, the client span was created from the botocore request-created event; since botocore creates a new AwsRequest event for every retry, these spans represent individual retries rather than the full event. Following OTel (https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/#rpc-client-span) the span should cover the entire call lifecycle including all retries. Wrapping _make_api_call() covers all retries performed by botocore, including serialization, endpoint resolution, the final response or failures (https://github.com/boto/botocore/blob/develop/botocore/client.py:999).

Changes

  • BaseClient._make_api_call() is patched such that one span is created for one boto3 operation; this span is kept active across every retry.
  • AwsCallContext class is added containing service, operation, region, etc for a a single call.
  • request-created is kept for breadcrumbs and HTTP attributes.
  • integration is moved into a new directory and split into a new files; public Boto3Integration is still unchanged, test was also added for this at boto3/test_client.py:20.
  • span name changed to Service.Operation, e.g. S3.HeadObject following OTel.
  • following attributes are added rpc.system.name, rpc.service, rpc.method, cloud.region, server.address, server.port.

Issues

Resolves #7474 & #7475

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

128609 passed | ⏭️ 7151 skipped | Total: 135760 | Pass Rate: 94.73% | Execution Time: 435m 12s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +303
Passed Tests 📈 +283
Failed Tests
Skipped Tests 📈 +20

All tests are passing successfully.

✅ Patch coverage is 92.55%. Project has 2541 uncovered lines.
✅ Project coverage is 90.21%. Comparing base (494ecb3) to head (8b42564).

Files with missing lines (3)
File Patch % Lines
sentry_sdk/integrations/boto3/_instrumentation.py 89.66% ⚠️ 21 Missing and 15 partials
sentry_sdk/integrations/boto3/_context.py 97.30% ⚠️ 1 Missing and 3 partials
sentry_sdk/integrations/boto3/_client.py 96.72% ⚠️ 2 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##        master       #PR       +/-##
==========================================
+ Coverage    90.17%    90.21%    +0.04%
==========================================
  Files          193       196        +3
  Lines        25773     25962      +189
  Branches      9532      9582       +50
==========================================
+ Hits         23241     23421      +180
- Misses        2532      2541        +9
- Partials      1431      1439        +8

Generated by Codecov Action

@pabloDeputter pabloDeputter changed the title feat(boto3): improve boto3 integration feat(boto3): trace logical AWS calls with common attributes Sep 11, 2026
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py Outdated
Comment thread sentry_sdk/consts.py
@pabloDeputter
pabloDeputter marked this pull request as ready for review September 14, 2026 09:26
@pabloDeputter
pabloDeputter requested a review from a team as a code owner September 14, 2026 09:26

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

Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
Comment thread tests/integrations/boto3/test_s3.py Outdated
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
Comment thread tests/integrations/boto3/test_client.py Outdated
@pabloDeputter
pabloDeputter added this pull request to stack #7500 September 14, 2026 12:53
Comment thread sentry_sdk/integrations/boto3/_client.py Outdated
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
Comment thread sentry_sdk/integrations/boto3/__init__.py Outdated
Comment thread sentry_sdk/integrations/boto3/_client.py Outdated
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
Comment thread sentry_sdk/integrations/boto3/_client.py Outdated
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 9fe9acf to 4e8f427 Compare September 14, 2026 14:42
Comment thread tests/integrations/boto3/test_client.py
Comment thread sentry_sdk/integrations/boto3/__init__.py
Comment thread sentry_sdk/integrations/boto3/_client.py Outdated

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

Comment thread sentry_sdk/integrations/boto3/_client.py Outdated
except BaseException as exc:
if span is not None:
with capture_internal_exceptions():
_finish_active_http_child_span(span)

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.

Why are we ending the stdlib span here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We finish the HTTP span before the parent boto3 span so that the correct order is preserved. Otherwise the HTTP span would be kept active until the whole response is read, while the parent boto3 span finishes first; afterwards when the HTTP span finishes, it will restore the already-finished parent as current, causing subsequent calls to be parented incorrectly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can send a screenshot from sentry maybe to show against latest release

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

old:
Screenshot 2026-09-15 at 14 18 55
new:
Screenshot 2026-09-15 at 14 18 46

@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from aa1d65a to 939a3f8 Compare September 15, 2026 12:58

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

Comment thread sentry_sdk/integrations/boto3/__init__.py

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

Comment thread sentry_sdk/integrations/boto3/_client.py Outdated

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 12e4678. Configure here.

Comment thread sentry_sdk/integrations/boto3/_client.py
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 50bb86d to ddf5deb Compare September 17, 2026 15:40
- wrapper owns a single botocore client-call lifecycle.
- introduce service-extension architecture.
- add generic response, retry, and error attributes.
- add common attributes that are the same across services.
…an naming and `rpc.service` and `parse_url` patch target
…er attributes; remove direct testing of `_get_server_attributes`
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from ddf5deb to 351e3b6 Compare September 17, 2026 15:50
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.

ref(boto3): Own one logical botocore client-call lifecycle

2 participants