-
Notifications
You must be signed in to change notification settings - Fork 631
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
Fix HTTP instrumentation not being suppressed #1116
Changes from 10 commits
5905853
6558b1e
7d35f17
f11bd39
10ddea2
ca62159
16004fb
130690f
2135e53
2b973a1
fde478d
2079f17
6d17119
8a50e59
1a3fed6
01a2bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
URLLibInstrumentor, | ||
) | ||
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY | ||
from opentelemetry.context import _SUPPRESS_HTTP_INSTRUMENTATION_KEY | ||
from opentelemetry.propagate import get_global_textmap, set_global_textmap | ||
from opentelemetry.sdk import resources | ||
from opentelemetry.semconv.trace import SpanAttributes | ||
|
@@ -188,6 +189,18 @@ def test_suppress_instrumentation(self): | |
|
||
self.assert_span(num_spans=0) | ||
|
||
def test_suppress_http_instrumentation(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a test that tests the scenario of being instrumented with multiple http instrumentations? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing a scenario with multiple http instrumentations would require testing across multiple packages at the same time (for example, requests and urllib3 to replicate the problem raised in issue #930) in the form of integration tests and not unit tests, which I think would be out of scope in this PR. |
||
token = context.attach( | ||
context.set_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY, True) | ||
) | ||
try: | ||
result = self.perform_request(self.URL) | ||
self.assertEqual(result.read(), b"Hello!") | ||
finally: | ||
context.detach(token) | ||
|
||
self.assert_span(num_spans=0) | ||
|
||
def test_not_recording(self): | ||
with mock.patch("opentelemetry.trace.INVALID_SPAN") as mock_span: | ||
URLLibInstrumentor().uninstrument() | ||
|
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.
This needs a FIXME to remind us to fix the importing of a private attribute when the location of the
_SUPPRESS_HTTP_INSTRUMENTATION_KEY
is defined.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.
Added, thanks for the feedback!