Skip to content

feat(boto3): Add common OTel AWS client attributes - #7481

Merged
pabloDeputter merged 6 commits into
pablo/trace-boto3-client-call-lifecyclefrom
pablo/improve-boto3-call-lifecycle
Sep 30, 2026
Merged

pabloDeputter merged 6 commits into
pablo/trace-boto3-client-call-lifecyclefrom
pablo/improve-boto3-call-lifecycle

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Description

Implements #7475 by adding common OTel attributes to boto client spans.

Changes

  • add the following attributes: rpc.system.name, rpc.service, rpc.method, cloud.region, server.address, server.port.
  • set rpc.system.name to aws-api
  • changing span name to Service.Operation (now it's aws.<service>.<Operation>), e.g. S3.HeadObject following OTel is a breaking change and will be done in major.
  • use modeled AWS service for rpc.service; not supported anymore by OTel, but JS keeps this too.
  • use boto operation name for rpc.method.
  • extend AwsCallContext to carry extra client metadata for instrumentation.

Issues

Resolves #7475

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 132565 passed | ⏭️ 7220 skipped | Total: 139785 | Pass Rate: 94.83% | Execution Time: 446m 31s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +3201
Passed Tests 📈 +3238
Failed Tests 📉 -60
Skipped Tests 📈 +23

➖ Removed Tests (60)

View removed tests
  • test_input_attributes_nonstreaming_chat[False-True-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-True-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-True-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-True-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-True-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-True-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-True-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-False-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat[False-False-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-True-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-True-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-True-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-True-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-False-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-True-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-True-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-True-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-True-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-True-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-False-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[True-False-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-True-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-True-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-True-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-True-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-False-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-True-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-True-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-True-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-True-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-True-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-False-messages0-expected_system_instructions0-expected_input_messages0]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-False-messages1-expected_system_instructions1-expected_input_messages1]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-False-messages2-expected_system_instructions2-expected_input_messages2]
    • File: tests.integrations.mistral.test_mistral
  • test_input_attributes_nonstreaming_chat_async[False-False-False-messages3-expected_system_instructions3-expected_input_messages3]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[True-True-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[True-True-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[True-False-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[True-False-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[False-True-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[False-True-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[False-False-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat[False-False-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[True-True-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[True-True-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[True-False-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[True-False-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[False-True-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[False-True-False]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[False-False-True]
    • File: tests.integrations.mistral.test_mistral
  • test_output_attributes_nonstreaming_chat_async[False-False-False]
    • File: tests.integrations.mistral.test_mistral
  • test_cache_spans_templatetag[True]
    • File: tests.integrations.django.test_cache_module

All tests are passing successfully.

✅ Patch coverage is 92.98%. Project has 2561 uncovered lines.
✅ Project coverage is 90.32%. Comparing base (2647da1) to head (6868ffd).

Files with missing lines (2)
File Patch % Lines
sentry_sdk/integrations/boto3/_instrumentation.py 89.19% ⚠️ 4 Missing and 3 partials
sentry_sdk/integrations/boto3/_context.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##        master       #PR       +/-##
==========================================
+ Coverage    90.30%    90.32%    +0.02%
==========================================
  Files          195       199        +4
  Lines        26261     26469      +208
  Branches      9798      9846       +48
==========================================
+ Hits         23714     23908      +194
- Misses        2547      2561       +14
- Partials      1485      1493        +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 Outdated
Comment thread sentry_sdk/integrations/boto3/__init__.py
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.

Stale Bugbot comment from a previous run.

Comment thread sentry_sdk/integrations/boto3/_client.py Outdated
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch 2 times, most recently from ddf5deb to 351e3b6 Compare September 17, 2026 15:50

@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
@pabloDeputter pabloDeputter changed the title feat(boto3): trace logical AWS calls with common attributes feat(boto3): add common OTel AWS client attributes Sep 18, 2026
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 3412f9b to 64d7159 Compare September 21, 2026 16:07

@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 64d7159. Configure here.

Comment thread sentry_sdk/integrations/boto3/_instrumentation.py
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch 2 times, most recently from 1824d8f to 3d95ef4 Compare September 22, 2026 09:18
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 3d95ef4 to f3ed486 Compare September 22, 2026 14:53
@pabloDeputter
pabloDeputter removed this pull request from stack #7541 September 22, 2026 14:57
@pabloDeputter
pabloDeputter added this pull request to stack #7618 September 22, 2026 14:57
) -> "Attributes":
attributes: "Attributes" = {}

# `rpc.service` is deprecated in OTel, but js still uses it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

They likely still use it because it's listed as a valid attribute in our conventions.

Not something for this pull request, but it might be worth raising this in our Slack channel for the conventions to see if this is something that we should look to deprecate as well.

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 was gonna make a collection of all new attributes that will be added during this project (including all the service-specific as well) to check which ones contain sensitive data and whether they already map to existing data collection categories. So I'll add rpc.service to that document as well.

Comment thread tests/integrations/boto3/test_client.py Outdated
assert span["name" if span_streaming else "description"] == span_name
assert attributes[SPANDATA.RPC_SERVICE] == rpc_service
assert attributes[SPANDATA.RPC_METHOD] == rpc_method
assert attributes[SPANDATA.RPC_SYSTEM_NAME] == "aws-api"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A small nitpick here (feel free to ignore): you could update the hard-coded string here to be the constant that you created in the other file.

Suggested change
assert attributes[SPANDATA.RPC_SYSTEM_NAME] == "aws-api"
assert attributes[SPANDATA.RPC_SYSTEM_NAME] == _AWS_RPC_SYSTEM_NAME

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.

Yupp, I'll move that to consts.py as well

Comment thread tests/integrations/boto3/test_client.py Outdated
Comment on lines +647 to +648
if span_streaming:
_assert_one_failed_span(client_spans, span_streaming=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Small cleanup suggestion: you could remove this conditional and the extra line inside the block by assigning the span_streaming variable to equal span_streaming:

Suggested change
if span_streaming:
_assert_one_failed_span(client_spans, span_streaming=True)
if span_streaming:
_assert_one_failed_span(client_spans, span_streaming=span_streaming)

@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 4562898 to dca0a7b Compare September 29, 2026 08:34
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from dca0a7b to 4a23000 Compare September 30, 2026 12:04
@pabloDeputter
pabloDeputter removed this pull request from stack #7618 September 30, 2026 12:05
@pabloDeputter
pabloDeputter added this pull request to stack #7792 September 30, 2026 12:05
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 4a23000 to 8b758b2 Compare September 30, 2026 13:31
Comment thread tests/integrations/boto3/test_client.py
@pabloDeputter
pabloDeputter force-pushed the pablo/improve-boto3-call-lifecycle branch from 8b758b2 to 6868ffd Compare September 30, 2026 14:05
@pabloDeputter
pabloDeputter merged commit 3f786a9 into master Sep 30, 2026
317 of 473 checks passed
@pabloDeputter
pabloDeputter deleted the pablo/improve-boto3-call-lifecycle branch September 30, 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.

feat(boto3): Add generic attributes that are common across services

3 participants