Skip to content

Commit

Permalink
try request ctx stack
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgrossman committed Mar 14, 2023
1 parent fb9161d commit 45198d7
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,9 @@ def _before_request():

activation = trace.use_span(span, end_on_exit=True)
activation.__enter__() # pylint: disable=E1101
breakpoint()
flask_request_environ[_ENVIRON_ACTIVATION_KEY] = activation
flask_request_environ[_ENVIRON_REQCTX_ID_KEY] = id(flask.request_ctx)
flask_request_environ[_ENVIRON_REQCTX_ID_KEY] = id(flask._request_ctx_stack.top)
flask_request_environ[_ENVIRON_SPAN_KEY] = span
flask_request_environ[_ENVIRON_TOKEN] = token

Expand Down Expand Up @@ -440,7 +441,7 @@ def _teardown_request(exc):
activation = flask.request.environ.get(_ENVIRON_ACTIVATION_KEY)

original_reqctx_id = flask.request.environ.get(_ENVIRON_REQCTX_ID_KEY)
current_reqctx_id = id(flask.request_ctx)
current_reqctx_id = id(flask._request_ctx_stack.top)
if not activation or original_reqctx_id != current_reqctx_id:
# 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 45198d7

Please sign in to comment.