Skip to content

Commit

Permalink
Update suppress http instrumentation key in all libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
carolabadeer committed Jun 2, 2022
1 parent 5905853 commit 6558b1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def response_hook(span, service_name, operation_name, result):
_SUPPRESS_INSTRUMENTATION_KEY,
unwrap,
)
from opentelemetry.context import (_SUPPRESS_HTTP_INSTRUMENTATION_KEY)
from opentelemetry.propagate import inject
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import get_tracer
Expand All @@ -108,10 +109,10 @@ def response_hook(span, service_name, operation_name, result):
# A key to a context variable to avoid creating duplicate spans when instrumenting
# both botocore.client and urllib3.connectionpool.HTTPConnectionPool.urlopen since
# botocore calls urlopen
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = context_api.create_key(
"suppress_http_instrumentation"
)

_BOTOCORE_INSTRUMENTATION_KEY = context_api.create_key(
"botocore_instrumentation"
)

# pylint: disable=unused-argument
def _patched_endpoint_prepare_request(wrapped, instance, args, kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from requests.sessions import Session
from requests.structures import CaseInsensitiveDict

from opentelemetry import context, trace
from opentelemetry import context
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.requests.package import _instruments
from opentelemetry.instrumentation.requests.version import __version__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def response_hook(span, request_obj, response)
_SUPPRESS_INSTRUMENTATION_KEY,
http_status_to_status_code,
)
from opentelemetry.context import _SUPPRESS_HTTP_INSTRUMENTATION_KEY
from opentelemetry.propagate import inject
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import Span, SpanKind, get_tracer
Expand All @@ -90,10 +91,9 @@ def response_hook(span, request_obj, response)

# A key to a context variable to avoid creating duplicate spans when instrumenting
# both, Session.request and Session.send, since Session.request calls into Session.send
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = context.create_key(
"suppress_http_instrumentation"
_URLLIB_INSTRUMENTATION_KEY = context.create_key(
"urllib_instrumentation"
)

_RequestHookT = typing.Optional[typing.Callable[[Span, Request], None]]
_ResponseHookT = typing.Optional[
typing.Callable[[Span, Request, client.HTTPResponse], None]
Expand Down

0 comments on commit 6558b1e

Please sign in to comment.