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

[requests] add unpatch and double-patch protection #404

Merged
merged 1 commit into from
Jan 29, 2018

Conversation

palazzem
Copy link

Overview

  • Adds protection to avoid double patch()
  • Adds unpatch() to remove tracing
  • Patches __init__ so that we can set later (another PR) settings from env vars

@palazzem palazzem added this to the 0.10.1 milestone Jan 29, 2018
_u(requests.Session, 'request')


def _session_initializer(func, instance, args, kwargs):
Copy link
Author

Choose a reason for hiding this comment

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

Not a big deal now, but it's required later

@palazzem palazzem force-pushed the palazzem/requests-double-patching branch from 405f3f6 to 9c78018 Compare January 29, 2018 13:13
eq_(len(spans), 1)
s = spans[0]
eq_(s.get_tag(http.METHOD), 'GET')
eq_(s.get_tag(http.STATUS_CODE), '500')
eq_(s.error, 1)


def get_traced_session():
Copy link
Author

Choose a reason for hiding this comment

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

Removed since a not monkey-patched class was used. With this new test suite, we ensure that patch() really updates the Session class.

from .patch import TracedSession, patch
__all__ = ['TracedSession', 'patch']
from .patch import TracedSession, patch, unpatch
__all__ = ['TracedSession', 'patch', 'unpatch']
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the deal to expose and document the unpatch method for this integration?

Copy link
Author

Choose a reason for hiding this comment

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

No actually no, it has been exposed only for testing purposes. We probably don't want to suggest patching and unpatching at runtime. Anyway there is a plan to refactor the patching system, since we should start to introduce settings for each integration.

Copy link
Contributor

@LotharSee LotharSee left a comment

Choose a reason for hiding this comment

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

Clean, gtm.

@palazzem palazzem merged commit eba304c into master Jan 29, 2018
@palazzem palazzem deleted the palazzem/requests-double-patching branch January 29, 2018 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants