Skip to content

Improve Pyramid integration#195

Merged
adamchainz merged 1 commit intomasterfrom
tidy_pyramid
Jun 28, 2019
Merged

Improve Pyramid integration#195
adamchainz merged 1 commit intomasterfrom
tidy_pyramid

Conversation

@adamchainz
Copy link
Copy Markdown
Contributor

  • Rearrange try/except so stop_span() will only be called if it was started
  • Use and test the full user_ip algorithm rather than just request.remote_addr, and reduce scope of its try/except
  • Improve some tests

* Rearrange `try/except` so `stop_span()` will only be called if it was started
* Use and test the full `user_ip` algorithm rather than just `request.remote_addr`, and reduce scope of its `try/except`
* Improve some tests
Copy link
Copy Markdown
Contributor

@dlanderson dlanderson left a comment

Choose a reason for hiding this comment

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

LGTM

tr.tag("ignore_transaction", True)
tracked_request.tag("ignore_transaction", True)

tracked_request.tag("path", request.path)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason we moved this outside the try? .path should supposedly always be present, but it's not critical in order for the TrackedRequest to work, and there's no harm in having it within the try where we do user_ip as well, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

request.path was already accessed outside of the try above - when I started writing a test to make it crash, I realized this.

@adamchainz adamchainz merged commit 742a84a into master Jun 28, 2019
@adamchainz adamchainz deleted the tidy_pyramid branch June 28, 2019 07:15
adamchainz added a commit that referenced this pull request Jun 29, 2019
After looking at whether this is needed in all tests for non-tracking, I realized this is already done for each test by the `isolate_global_state` fixture in `tests/conftest.py`. Therefore removing the redundant assertions added in #195.
adamchainz added a commit that referenced this pull request Jun 29, 2019
After looking at whether this is needed in all tests for non-tracking, I realized this is already done for each test by the `isolate_global_state` fixture in `tests/conftest.py`. Therefore removing the redundant assertions added in #195.
adamchainz added a commit that referenced this pull request Oct 23, 2019
Both the Bottle and Pyramid integrations have this overly cautious behaviour around reading headers from the upstream framework. They both assume that basic framework operations such as fetching a header can fail, and guard around it.

Some of this came from my refactoring for Bottle in #192 and Pyramid in #195, where I narrowed large `try/except` blocks down, but didn't rethink this paranoia.

I think this is too cautious and can be removed. It required a lot of extra lines for the two frameworks when adding Amazon request queue timing in #279, to really no extra effect. If fetching headers (with safe defaults) is broken, users' applications are pretty much guaranteed to be broken too.
adamchainz added a commit that referenced this pull request Oct 23, 2019
Both the Bottle and Pyramid integrations have this overly cautious behaviour around reading headers from the upstream framework. They both assume that basic framework operations such as fetching a header can fail, and guard around it.

Some of this came from my refactoring for Bottle in #192 and Pyramid in #195, where I narrowed large `try/except` blocks down, but didn't rethink this paranoia.

I think this is too cautious and can be removed. It required a lot of extra lines for the two frameworks when adding Amazon request queue timing in #279, to really no extra effect. If fetching headers (with safe defaults) is broken, users' applications are pretty much guaranteed to be broken too.
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.

2 participants