Improvements for requests integration#573
Improvements for requests integration#573toumorokoshi merged 12 commits intoopen-telemetry:masterfrom mauriciovasquezbernal:mauricio/update-http-requests
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.
should disable_session be used here as well?
There was a problem hiding this comment.
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.
codeboten
left a comment
There was a problem hiding this comment.
Change looks good, just a minor suggestion in the code. We should probably also have documentation reflecting how to disable instrumentation for a session.
toumorokoshi
left a comment
There was a problem hiding this comment.
LGTM! Let me merge the tests one first and then you can rebase + merge this one.
| ) | ||
|
|
||
|
|
||
| class TestBase(unittest.TestCase): |
| 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.
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.mockto SDK & in-memory exporter #303)Fixes #479
This will conflict with #559, I can update it when that's merged.