Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgrossman committed Mar 14, 2023
1 parent 6f7835a commit 4bcc1df
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ def response_hook(span: Span, status: str, response_headers: List):

_logger = getLogger(__name__)

class _TraceContext(typing.NamedTuple):
starttime: int

_ENVIRON_STARTTIME_KEY = "opentelemetry-flask.starttime_key"
_ENVIRON_SPAN_KEY = "opentelemetry-flask.span_key"
_ENVIRON_ACTIVATION_KEY = "opentelemetry-flask.activation_key"
Expand All @@ -277,16 +274,9 @@ class _TraceContext(typing.NamedTuple):
if package_version.parse(flask.__version__) >= package_version.parse("2.2.0"):
def _request_ctx_ref() -> weakref.ReferenceType:
return weakref.ref(flask.globals.request_ctx._get_current_object())
def _request_ctx() -> RequestContext:
return flask.globals.request_ctx._get_current_object()
else:
def _request_ctx_ref() -> int:
return weakref.ref(flask._request_ctx_stack.top)
def _request_ctx() -> RequestContext:
return flask._request_ctx_stack.top

def _get_reqctx():
return flask._request_ctx_stack.top

def get_default_span_name():
try:
Expand Down Expand Up @@ -416,16 +406,11 @@ def _before_request():
activation = trace.use_span(span, end_on_exit=True)
activation.__enter__() # pylint: disable=E1101

reqctx = _get_reqctx()
flask_request_environ[_ENVIRON_ACTIVATION_KEY] = activation

flask_request_environ[_ENVIRON_REQCTX_REF_KEY] = _request_ctx_ref()
flask_request_environ[_ENVIRON_SPAN_KEY] = span
flask_request_environ[_ENVIRON_TOKEN] = token

reqctx = _get_reqctx()
reqctx._test_ref = _request_ctx_ref()

if enable_commenter:
current_context = context.get_current()
flask_info = {}
Expand Down Expand Up @@ -465,9 +450,6 @@ def _teardown_request(exc):

original_reqctx_ref = flask.request.environ.get(_ENVIRON_REQCTX_REF_KEY)
current_reqctx_ref = _request_ctx_ref()
# tear_request FROM the copy_current_Request_context's teardown
if 'asdf' in flask.g:
breakpoint()
if not activation or original_reqctx_ref != current_reqctx_ref:
# This request didn't start a span, maybe because it was created in
# a way that doesn't run `before_request`, like when it is created
Expand Down

0 comments on commit 4bcc1df

Please sign in to comment.