-
Notifications
You must be signed in to change notification settings - Fork 649
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
Improvements for requests integration #573
Improvements for requests integration #573
Conversation
TestBase class wraps a tracer provider that is configured with a memory span exporter. This class inherits from unitest.TestCase, hence other test classes can inherit from it to get access to the underlying memory span exporter and tracer provider.
This mock propagator could be use for testing propagation in different packages. It was implemented in the opentracing-shim and this commit moves it to a generic place.
disable_session() can be used to disable the instrumentation on a single requests' session object.
This commit refactor the tests: - Use the TestBase class, removing all the mocking around - Add new tests
@@ -129,3 +127,10 @@ def disable(): | |||
if getattr(Session.request, "opentelemetry_ext_requests_applied", False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should disable_session
be used here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are slightly different, this one modifies Session.request
, i.e, the method in the whole class, while disable_session only modifies the request method on that object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, just a minor suggestion in the code. We should probably also have documentation reflecting how to disable instrumentation for a session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Let me merge the tests one first and then you can rebase + merge this one.
) | ||
|
||
|
||
class TestBase(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! good call.
span_list = self.memory_exporter.get_finished_spans() | ||
self.assertEqual(len(span_list), 1) | ||
|
||
def test_suppress_instrumentation(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to this PR, but you reminded me that we should handle instrumentation suppression on a different layer: #581. Then we can remove this test.
* chore: add missing default plugins * chore: update plugin list
I started porting the Datadog version of this integration (open-telemetry/opentelemetry-python-contrib#23) to get familiar with the process, while doing so I realized some of the things we are missing in the current integration. The goal of this PR is to improve the current implementation / tests, in a following PR the instrumentor logic will be added.
unittest.mock
to SDK & in-memory exporter #303)Fixes #479
This will conflict with #559, I can update it when that's merged.