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

feat(envelope): Add some useful envelope methods #793

Merged
merged 12 commits into from Sep 24, 2020

Conversation

dashed
Copy link
Member

@dashed dashed commented Aug 21, 2020

Add some useful envelope methods needed for integration tests in getsentry/relay#724

TODO

  • add some tests

sentry_sdk/envelope.py Outdated Show resolved Hide resolved
@dashed dashed requested a review from Zylphrex August 21, 2020 18:06
@dashed dashed requested review from rhcarvalho and a team September 11, 2020 21:10
@dashed dashed force-pushed the add-useful-envelope-methods branch 2 times, most recently from 23e7c08 to 2470fcd Compare September 12, 2020 00:03
sentry_sdk/envelope.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

@dashed I see you want this for getsentry/relay#724, but since the code is not used neither here nor in the Relay PR, it is hard to judge whether it actually helps writing what you're trying to write ;)

One suggestion would be to add simple tests here in sentry-python to showcase the usage (I would not expect someone maintaining this repo to have to read Relay tests).

# t = ...
e = Envelope()
e.add_transaction(t)
with pytest.raises(ValueError):
    e.add_transaction(t)  # can only have 1 transaction in the envelope
assert e.get_transaction() is t

Since there can only be one transaction, perhaps a better API for the present would be a single property -- with the drawback of getting ugly if we ever allow more than 1 transaction per envelope. If that ever happens we can deprecate the property and add add_transaction, perhaps not a big deal.

# t = ...
e = Envelope()
t.transaction = t  # behind the scenes this either adds or replaces an envelope item
assert t.transaction == t

sentry_sdk/envelope.py Outdated Show resolved Hide resolved
sentry_sdk/envelope.py Show resolved Hide resolved
sentry_sdk/envelope.py Outdated Show resolved Hide resolved
sentry_sdk/envelope.py Outdated Show resolved Hide resolved
sentry_sdk/envelope.py Outdated Show resolved Hide resolved
@dashed dashed force-pushed the add-useful-envelope-methods branch 2 times, most recently from 3113f0f to f0ba04e Compare September 15, 2020 21:09
@dashed
Copy link
Member Author

dashed commented Sep 23, 2020

@rhcarvalho I've added some tests 1e29b2a

@dashed dashed requested review from untitaker and removed request for untitaker September 23, 2020 17:54
@untitaker untitaker merged commit e234998 into master Sep 24, 2020
@untitaker untitaker deleted the add-useful-envelope-methods branch September 24, 2020 08:02
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.

None yet

4 participants