Skip to content

Add transport worker factory and abstract base class for background worker #4580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: srothh/transport-class-hierarchy
Choose a base branch
from

Conversation

srothh
Copy link
Member

@srothh srothh commented Jul 14, 2025

Add a new abstract base class for the background worker implementations in the transport. This allows for implementation of the upcoming async task-based worker in addition to the current thread based worker used in the sync context. Additionally, add a factory method in the HttpTransportCore shared class, to allow the worker methods to live higher up in the class hierarchy regardless of specific implementation.

GH-4578

srothh added 2 commits July 14, 2025 14:18
Add an abstract bass class for implementation of the background worker. This was done to provide a shared interface for the current
implementation of a threaded worker in the sync context as well as the upcoming async task-based worker implementation.

GH-4578
Add a new factory method instead of direct instatiation of the threaded background worker.
This allows for easy extension to other types of workers, such as the upcoming task-based async worker.

GH-4578
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.90%. Comparing base (fe27100) to head (a6be4a3).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/worker.py 73.68% 5 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           srothh/transport-class-hierarchy    #4580      +/-   ##
====================================================================
- Coverage                             84.90%   84.90%   -0.01%     
====================================================================
  Files                                   158      144      -14     
  Lines                                 15373    15044     -329     
  Branches                               2423     2377      -46     
====================================================================
- Hits                                  13053    12773     -280     
+ Misses                                 1573     1543      -30     
+ Partials                                747      728      -19     
Files with missing lines Coverage Δ
sentry_sdk/transport.py 84.22% <100.00%> (+0.08%) ⬆️
sentry_sdk/worker.py 77.67% <73.68%> (-1.05%) ⬇️

... and 22 files with indirect coverage changes

@srothh
Copy link
Member Author

srothh commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.90%. Comparing base (fe27100) to head (a6be4a3).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/worker.py 73.68% 5 Missing ⚠️
Additional details and impacted files

The uncovered lines of code here are just the pass calls from the abstract class definition.

srothh added 5 commits July 17, 2025 11:51
…ass-hierarchy

ref(transport): Add flush_async to Transport ABC
Add a new flush_async method to worker ABC. This is necessary because the async transport cannot use a
synchronous blocking flush.

GH-4578
…ass-hierarchy

Merge the class structure changes from transport
Move the flush_async down to the concrete subclass to not break existing testing. This makes sense,
as this will only really be needed by the async worker anyway and therefore is not shared logic.

GH-4578
Coroutines have a return value, however the current function signature for the worker methods does not
accomodate for this. Therefore, this signature was changed.

GH-4578
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