Skip to content

Commit 45198d7

Browse files
try request ctx stack
1 parent fb9161d commit 45198d7

File tree

1 file changed

+3
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask

1 file changed

+3
-2
lines changed

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ def _before_request():
397397

398398
activation = trace.use_span(span, end_on_exit=True)
399399
activation.__enter__() # pylint: disable=E1101
400+
breakpoint()
400401
flask_request_environ[_ENVIRON_ACTIVATION_KEY] = activation
401-
flask_request_environ[_ENVIRON_REQCTX_ID_KEY] = id(flask.request_ctx)
402+
flask_request_environ[_ENVIRON_REQCTX_ID_KEY] = id(flask._request_ctx_stack.top)
402403
flask_request_environ[_ENVIRON_SPAN_KEY] = span
403404
flask_request_environ[_ENVIRON_TOKEN] = token
404405

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

442443
original_reqctx_id = flask.request.environ.get(_ENVIRON_REQCTX_ID_KEY)
443-
current_reqctx_id = id(flask.request_ctx)
444+
current_reqctx_id = id(flask._request_ctx_stack.top)
444445
if not activation or original_reqctx_id != current_reqctx_id:
445446
# This request didn't start a span, maybe because it was created in
446447
# a way that doesn't run `before_request`, like when it is created

0 commit comments

Comments
 (0)