-
Notifications
You must be signed in to change notification settings - Fork 621
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 issue with Flask instrumentation when a request spawn children threads and copies the request context #1654
Fix issue with Flask instrumentation when a request spawn children threads and copies the request context #1654
Conversation
|
Please add a changelog entry |
1676b09
to
76ebf6c
Compare
Updated. Thanks for the help. |
76ebf6c
to
1e36cca
Compare
5009231
to
b0db5ab
Compare
...tion/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
Outdated
Show resolved
Hide resolved
I am not familiar with flask requests, |
b0db5ab
to
cd89ca9
Compare
...tion/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
Outdated
Show resolved
Hide resolved
I can't think of any legitimate reason for that because it won't serve any useful purpose. It's definitely possible but it won't make any sense. |
cd89ca9
to
eb7a406
Compare
...tion/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
Show resolved
Hide resolved
…reads and copie the request context
799e84e
to
81e38e4
Compare
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.
my approval in this repo doesn't mean anything, but just to echo from the initial issue that this will solve my issue
fixes #1551
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
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.
Thanks for the informative PR description! I'm not super familiar with this but the solution makes sense to me after reading through.
How difficult would it be to add a unit test for this?
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
0237c2f
to
f063515
Compare
@aabmass Good idea. Added new test case |
f063515
to
4882ca4
Compare
Head branch was pushed to by a user without write access
4882ca4
to
747924c
Compare
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.
Looks great! Thanks again
747924c
to
638c042
Compare
075cff2
to
efe9b8d
Compare
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.
Thanks
…/github.com/shalevr/opentelemetry-python-contrib into Change-metrics-tests-to-work-with-test_base * 'Change-metrics-tests-to-work-with-test_base' of https://github.com/shalevr/opentelemetry-python-contrib: Fix issue with Flask instrumentation when a request spawn children threads and copies the request context (open-telemetry#1654) Add connection attributes to sqlalchemy connect span (open-telemetry#1608) Add boto3sqs to docs (open-telemetry#1666) Audit and test opentelemetry-instrumentation-elasticsearch NoOpTracer… (open-telemetry#1616) Copy change log updates from release/v1.16.x-0.37bx (open-telemetry#1683) Update version to 1.17.0.dev/0.38b0.dev (open-telemetry#1677) Fix CI Failure (open-telemetry#1680) Add better debugging if hatch subprocess fails (open-telemetry#1672) Add confluent kafka docs (open-telemetry#1668) Support aio_pika 9 (open-telemetry#1670) Audit and test opentelemetry-instrumentation-wsgi NoOpTracerProvider (open-telemetry#1610) bot (open-telemetry#1667) Add commit method for ConfluentKafkaInstrumentor's ProxiedConsumer (open-telemetry#1656) Revert open-telemetry#1097 (open-telemetry#1660) Audit and test opentelemetry-instrumentation-django NoOpTracerProvider (open-telemetry#1611) Audit and test opentelemetry-instrumentation-aiohttp-client NoOpTrace… (open-telemetry#1612) Audit and test opentelemetry-instrumentation-flask NoOpTracerProvider (open-telemetry#1614) Audit and test opentelemetry-instrumentation-dbapi NoOpTracerProvider (open-telemetry#1607)
…reads and copies the request context (open-telemetry#1654)
Description
In
opentelemetry.instrumentation.flask
record the thread ID in_before_request
in addition to the span. Then in_teardown_request
check that it's the same thread for that span before callingactivation.__exit__
Fixes #1653
Fixes #1551
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
The bug is reproducible with this simple Flask app:
When run with
opentelemetry-instrument --traces_exporter console --metrics_exporter console flask run
and accessed using HTTP it results inAfter the change, the issue no longer appears and the trace appears in the console.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.