Skip to content

Support for Python SDK 3.0.0 #92011

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 25 commits into
base: master
Choose a base branch
from

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented May 21, 2025

[work in progress]

Sentry SDK 3.0.0 has massive changes on how the data flows through the SDK compared to 2.x. (3.0 uses Opentelementry under the hood to create spans)

Some APIs in 3.0 is not backwards compatible with 2.x so we need to change a lot of call sites.

Still ToDo (not an exhaustive list):

  • remove custom_sampling_context everywhere in code base (given to spans)
  • set_attribute type NOT a dict. (search for TODO-anton in PR files changed)
  • attributes in start_span can NOT be a dict.
  • change set_span_data() to set_span_attribute() but check for value NOT be a dict.

What this PR does:

  • removed propagate_hub=True from ThreadingIntegration
  • removed the @mmetrics_noop decorator, because there are no metrics anymore only span.data, so we do not need it.
  • moved sampled=False from assigning to a span into the start_span() call.
  • replaces span.set_data with span.set_attribute with the same params
  • changed one scope.add_attachment to sentry_sdk.add_attachment
  • changed all .start_transaction() to .start_span() (without ever setting only_if_parent)
  • changed custom_sampling_context param in .start_span() to attributes
  • changed one continue_trace to the new context manager.
  • removed helper src/sentry/utils/sdk.py::set_measurement() because it is not used in sentry.
  • replaced scope.transaction with scope.root_span
  • replaced sentry_sdk.Scope.get_*_scope() with sentry_sdk.get_*_scope()

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 21, 2025
Copy link

codecov bot commented May 21, 2025

❌ 119 Tests Failed:

Tests completed Failed Passed Skipped
24885 119 24766 199
View the top 3 failed test(s) by shortest run time
tests.sentry.taskworker.test_worker::test_child_process_terminate_task
Stack Traces | 0.076s run time
#x1B[1m#x1B[.../sentry/taskworker/test_worker.py#x1B[0m:516: in test_child_process_terminate_task
    assert type(mock_capture.call_args.args[0]) is ProcessingDeadlineExceeded
#x1B[1m#x1B[31mE   assert <class 'TypeError'> is ProcessingDeadlineExceeded#x1B[0m
#x1B[1m#x1B[31mE    +  where <class 'TypeError'> = type(TypeError("Span.__init__() got an unexpected keyword argument 'environ_or_headers'"))#x1B[0m
tests.sentry.taskworker.test_worker::test_child_process_unknown_task
Stack Traces | 0.083s run time
#x1B[1m#x1B[.../sentry/taskworker/test_worker.py#x1B[0m:424: in test_child_process_unknown_task
    assert result.status == TASK_ACTIVATION_STATUS_COMPLETE
#x1B[1m#x1B[31mE   AssertionError: assert 3 == 5#x1B[0m
#x1B[1m#x1B[31mE    +  where 3 = ProcessingResult(task_id='111', status=3).status#x1B[0m
tests.sentry.taskworker.test_worker::test_child_process_retry_task
Stack Traces | 0.116s run time
#x1B[1m#x1B[.../sentry/taskworker/test_worker.py#x1B[0m:354: in test_child_process_retry_task
    assert result.status == TASK_ACTIVATION_STATUS_RETRY
#x1B[1m#x1B[31mE   AssertionError: assert 3 == 4#x1B[0m
#x1B[1m#x1B[31mE    +  where 3 = ProcessingResult(task_id='222', status=3).status#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant