Skip to content
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

ref(api): Remove store endpoint #2656

Merged
merged 31 commits into from Jan 29, 2024

Conversation

szokeasaurusrex
Copy link
Member

@szokeasaurusrex szokeasaurusrex commented Jan 18, 2024

Summary

This change removes all usages of the deprecated store endpoint from the Python SDK. From now on, events that were previously sent to the store endpoint will now be sent as envelopes to the envelope endpoint.

Breaking API changes

  • sentry_sdk.transport.Transport is now an abstract base class, and therefore, it cannot be instantiated directly. Subclasses must implement the capture_envelope method.
  • sentry_sdk.utils.Auth.store_api_url has been removed.
  • sentry_sdk.utils.Auth.get_api_url's now accepts a sentry_sdk.consts.EndpointType enum instead of a string as its only parameter. Supplying this parameter is currently unnecessary, since the parameter's default value is the only possible sentry_sdk.consts.EndpointType value.

Backwards-compatible API changes

  • sentry_sdk.transport.Transport.capture_event has been deprecated. Please use sentry_sdk.transport.Transport.capture_envelope, instead.
  • Passing a function to sentry_sdk.init's transport keyword argument has been deprecated. If you wish to provide a custom transport, please pass a sentry_sdk.transport.Transport instance or a subclass.

Other changes

  • sentry_sdk.transport.HttpTransport._send_event has been removed, and uses of this method have been removed from the codebase, including from tests.
  • Cleaned up some transport-related test code

Fixes GH-1957


General Notes

Thank you for contributing to sentry-python!

Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.

For maintainers

Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.

Before running sensitive test suites, please carefully check the PR. Then, apply the Trigger: tests using secrets label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.

tests/conftest.py Outdated Show resolved Hide resolved
@cleptric cleptric self-requested a review January 18, 2024 16:34
@szokeasaurusrex szokeasaurusrex linked an issue Jan 19, 2024 that may be closed by this pull request
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review January 22, 2024 14:33
Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

https://github.com/getsentry/sentry-python/blob/sentry-sdk-2.0/sentry_sdk/scope.py#L613-L629

This can also be cleaned up.

  • Remove the has_tracing_enabled check
  • We do not need to set the replay context anymore; this was a workaround applying to the /store endpoint only

sentry_sdk/scope.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

LGTM in general. Left a couple of comments.

Also, there's a migration guide on the 2.0 branch, please update it and add to this PR.

@@ -1,12 +1,16 @@
from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this on the 2.0 branch because there's no Python 2 support anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch – I think Git somehow put this line in when I was splitting the Transport ABC stuff into a separate PR

@@ -183,27 +179,23 @@ def inner(
response["Payload"] = json.loads(response["Payload"].read().decode("utf-8"))
del response["ResponseMetadata"]

events = []
envelopes = []
envelope_item = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not keep calling this envelopes? That's the usual convention in our tests. Or maybe at least envelope_items, since it's a collection of items rather than one item?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the change because we are actually capturing envelope Items here, not Envelopes. The previous naming confused me when I was looking at the tests, because I thought these were Envelope objects, and I thought I would have to somehow manually extract the events (i.e. Items) from them. The name envelope_items makes it clear that we are dealing with Item objects, not Envelope objects, here.

I believe the that in the "usual convention" you are referring to, we are capturing the envelopes using the capture_envelopes fixture, which returns a list[Envelope]. Therefore, while the envelopes name is the appropriate choice in those cases, the distinct envelope_items name here is warranted because here we have a list[Item], which we need to handle differently.

You are right though, we should be calling this variable envelope_items rather than envelope_item. I will make this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then let's go with envelope_items 👍🏻

tests/integrations/gcp/test_gcp.py Show resolved Hide resolved
tests/test_client.py Show resolved Hide resolved
@szokeasaurusrex szokeasaurusrex marked this pull request as draft January 24, 2024 15:03
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review January 25, 2024 15:06
Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

As you walked me through the changes already, this looks good to me!

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Please see one comment about the migration guide, otherwise LGTM

MIGRATION_GUIDE.md Outdated Show resolved Hide resolved
@szokeasaurusrex szokeasaurusrex merged commit ddb4a29 into sentry-sdk-2.0 Jan 29, 2024
110 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/remove-store-endpoint branch January 29, 2024 17:19
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.

Sun-setting the /store endpoint
4 participants