GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(boto3): Add `ServiceExtension` class by pabloDeputter · Pull Request #7536 · getsentry/sentry-python

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Sep 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Adds service-extension support to Boto3Integration. This keeps the generic Boto3 call lifecycle independent of individual AWS services.

  • Adds _ServiceExtension interface for service-specific behavior through _get_span_config(), _get_request_attributes(), and _get_response_attributes(). This allows for custom span operations/origin, request attributes, and response/error attributes. A future method can also inject trace context into service-specific payload, e.g. SQS message attributes.
  • Extensions are lazily imported (not sure whether this actually a good thing). Service modules are only imported on first use and falls back to generic behavior when service is unknown or broken.
  • Generic attributes and errors remain authoritative over service-specific ones.
  • sentry.kind is added to every boto3 span and defaults to sentry.kind="client"; service extensions can override this later, e.g. SQS/SNS send sentry.kind="producer" or SQS receive use sentry.kind="consumer" / sentry.kind="client"

Issues

Resolves #7477

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pabloDeputter
pabloDeputter added this pull request to stack #7500 September 18, 2026 13:31
@github-actions

github-actions Bot commented Sep 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 132793 passed | ⏭️ 7220 skipped | Total: 140013 | Pass Rate: 94.84% | Execution Time: 461m 39s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -65
Passed Tests 📉 -65
Failed Tests —
Skipped Tests —

All tests are passing successfully.

✅ Patch coverage is 97.67%. Project has 2563 uncovered lines.
❌ Project coverage is 90.35%. Comparing base (e899330) to head (2eef01e).

Files with missing lines (3)
File Patch % Lines
sentry_sdk/integrations/boto3/_instrumentation.py 100.00% ⚠️ 3 partials
sentry_sdk/integrations/boto3/_services/registry.py 83.33% ⚠️ 1 Missing and 1 partials
sentry_sdk/integrations/boto3/_services/base.py 90.91% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##        master       #PR       +/-##
==========================================
- Coverage    90.37%    90.35%    -0.02%
==========================================
  Files          199       202        +3
  Lines        26526     26551       +25
  Branches      9866      9856       -10
==========================================
+ Hits         23971     23988       +17
- Misses        2555      2563        +8
- Partials      1495      1487        -8

Generated by Codecov Action

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sentry-warden[bot]
sentry-warden Bot reviewed Sep 18, 2026
View reviewed changes
Comment thread sentry_sdk/integrations/boto3/_services/registry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pabloDeputter
pabloDeputter removed this pull request from stack #7500 September 18, 2026 14:34
@pabloDeputter
pabloDeputter added this pull request to stack #7539 September 18, 2026 14:35
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 499dbcc to d9609eb Compare September 18, 2026 15:06
@pabloDeputter
pabloDeputter removed this pull request from stack #7539 September 18, 2026 15:08
@pabloDeputter
pabloDeputter added this pull request to stack #7541 September 18, 2026 15:08
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from d9609eb to ea505d1 Compare September 18, 2026 15:20
sentry-warden[bot]
sentry-warden Bot reviewed Sep 18, 2026
View reviewed changes
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch 2 times, most recently from 9068e22 to b9071e2 Compare September 21, 2026 15:42
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from b9071e2 to 787cd71 Compare September 21, 2026 16:07
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 17d48a0 to 8ace874 Compare September 22, 2026 08:52
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 82e40da to 2de4cfe Compare September 22, 2026 09:18
@pabloDeputter
pabloDeputter marked this pull request as ready for review September 22, 2026 11:50
@pabloDeputter
pabloDeputter requested a review from a team as a code owner September 22, 2026 11:50
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from d8279cc to d7727cd 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
ericapisani
ericapisani reviewed Sep 28, 2026
View reviewed changes
Comment thread sentry_sdk/integrations/boto3/_services/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/boto3/_services/base.py Outdated
def get_span_config(
self, ctx: "AwsCallContext"
) -> "Optional[Tuple[Optional[str], Optional[str]]]":
"""Return an optional `(op, origin)` override for the client span."""

@ericapisani ericapisani Sep 28, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

To confirm, the op, origin here is referring to the values that would normally live in the sentry.op and sentry.origin span attributes?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pabloDeputter pabloDeputter Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yupp, I originally I had 2 separate hooks for sentry.op and sentry.origin; not sure why I changed it to a single one. I changed it back to 2 separate ones since it’s more clear.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ericapisani reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Comment thread sentry_sdk/integrations/boto3/_services/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/boto3/_services/registry.py Outdated
from typing import Dict, Optional, Tuple


# service modules are imported lazily.

@ericapisani ericapisani Sep 28, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I saw the comment about this in the pull request summary and was wondering - do we know why this happens?

Not sure if you've learned the background on this design choice as you've been making changes in this integration. 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pabloDeputter pabloDeputter Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I wanted to first discuss with someone on whether this was a good approach or not, but didn’t get the chance. The idea was that a specific service module (e.g. _services/s3.py) would only be loaded at the time it was needed (first client call that needs it).

This is probably not needed when there are only a few number of extensions (final target is ~9), but might improve performance if there are more and have a number of dependencies/are large? I’m really not sure about this, the gains would probably negligible compared to the variance in network calls…

I guess it’s easier to just start with a static map like this, what do you think?

from sentry_sdk.integrations.boto3._services.s3 import _S3Extension

_SERVICE_EXTENSIONS = {
	“s3”: _S3Extension
}

def _resolve_service(service_name: str):
	return _SERVICE_EXTENSIONS.get(service_name)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ericapisani ericapisani Sep 29, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah, I think the static map approach would be easier to start with, and if we see that we're starting to impact performance we can revisit this.

As an aside, I think we may take a harder look at our lazy-loading approach once Python 3.15 drops with the lazy keyword support

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pabloDeputter reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread sentry_sdk/integrations/boto3/_services/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/boto3/_instrumentation.py Outdated
with capture_internal_exceptions():
attributes.update(service_ext.get_request_attributes(ctx))

# Generic attributes take precedence over service-specific attributes.

@ericapisani ericapisani Sep 28, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm not sure I follow why we want this to happen. Could you provide some context on why we'd rather this than the other way around (service-specific overrides generic)?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pabloDeputter pabloDeputter Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not sure why I did this (maybe for future AWS services there might be overlap between attributes, but I doubt it). Even if there is overlap, I think you would want service-precedence or just decide for that specific attribute which one should be kept.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pabloDeputter pabloDeputter Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I put it back that generic attributes are set first, service-specific ones are set later.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ericapisani reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 91c9bdb to 226f56a Compare September 30, 2026 15:30
cursor[bot]
cursor Bot reviewed Sep 30, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 226f56a. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/boto3/_instrumentation.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Base automatically changed from pablo/add-boto3-response-retry-error-attributes to master September 30, 2026 15:50
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 226f56a to 4d0bd32 Compare September 30, 2026 15:50
pabloDeputter and others added 22 commits October 1, 2026 13:45
@pabloDeputter
add base ServiceExtension class
abc5376
@pabloDeputter
feat(boto3): Add service registry
3b0a892
@pabloDeputter
add missing __init__.py file
6a25b5a
@pabloDeputter
simplify _resolve_service() logic
442d70c
@pabloDeputter
add service extension logic to _instrumentation.py
2e78861
@pabloDeputter
combine span-config extraction and validation in _start_client_span()
10f8b8a
@pabloDeputter
add service extension logic to _client.py
b58af72
@pabloDeputter
add tests
a907d7e
@pabloDeputter
fix(boto3): Remove "hardcoded" origin
9688571
- otherwise service-specific spans with different origins would be skipped (e.g. DynamoDB)
@pabloDeputter
feat(boto3): Add sentry.kind attribute to boto span
5cb454f
@pabloDeputter
ref(boto3): Add comment explaining
d0224f1
@pabloDeputter @ericapisani
Update sentry_sdk/integrations/boto3/_services/base.py
e9e349c
ref(boto3): improve docstring for `get_request_attributes()`

Co-authored-by: Erica Pisani <[email protected]>
@pabloDeputter
fix(boto3): correct AWS_RPC_SYSTEM_NAME constant
ba5a0f5
@pabloDeputter
ref(boto3): refactor get_span_config() into get_span_op() and `ge…
e3eb77a
…t_span_origin()`
@pabloDeputter
ref(boto3): remove attribute-precedence
4e21a85
@pabloDeputter
ref(boto3): remove lazy-loading approach; replace with static map
25b893e
@pabloDeputter
fix(boto3): make logic clearer
7e175d4
@pabloDeputter
ref(boto3): change comment's and simplify logic
46ab807
@pabloDeputter
ref(boto3): remove defensive checks
023a891
@pabloDeputter
ref(boto3): remove defensive checks and cleanup comments
7fab0a8
@pabloDeputter
cleanup tests
5e64de7
@pabloDeputter
remove AI comment
2eef01e
@pabloDeputter
pabloDeputter force-pushed the pablo/add-boto3-service-extension-class branch from 4d0bd32 to 2eef01e Compare October 1, 2026 11:47
@pabloDeputter
pabloDeputter merged commit 014769c into master Oct 1, 2026
161 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pabloDeputter
pabloDeputter deleted the pablo/add-boto3-service-extension-class branch October 1, 2026 12:04
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Oct 12, 2026
publish: getsentry/[email protected] getsentry/publish#9830
Closed
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@sentry-warden sentry-warden[bot] sentry-warden[bot] left review comments
@ericapisani ericapisani ericapisani approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

feat(boto3): Add-service extension class

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pabloDeputter @ericapisani
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.