Skip to content

Improvements for requests integration#573

Merged
toumorokoshi merged 12 commits intoopen-telemetry:masterfrom
mauriciovasquezbernal:mauricio/update-http-requests
Apr 15, 2020
Merged

Improvements for requests integration#573
toumorokoshi merged 12 commits intoopen-telemetry:masterfrom
mauriciovasquezbernal:mauricio/update-http-requests

Conversation

@mauriciovasquezbernal
Copy link
Copy Markdown
Member

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.

Fixes #479

This will conflict with #559, I can update it when that's merged.

c24t and others added 7 commits April 6, 2020 15:22
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):
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.

should disable_session be used here as well?

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Contributor

@codeboten codeboten left a 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.

Copy link
Copy Markdown
Member

@toumorokoshi toumorokoshi left a 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):
Copy link
Copy Markdown
Member

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):
Copy link
Copy Markdown
Member

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.

@toumorokoshi toumorokoshi merged commit 44b592c into open-telemetry:master Apr 15, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: add missing default plugins

* chore: update plugin list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opentelemetry.ext.http_requests should allow de-registering a specific Session

4 participants