open-telemetry / open-telemetry/opentelemetry-python-contrib
"Failed to detach context" error in Open Telemetry tornado instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
opentelemetry-api==1.9.1
opentelemetry-sdk==1.9.1
opentelemetry-instrumentation-tornado==0.28b1
python 3.8 alpine docker image
enabled traces using SimpleSpanProcessor and ConsoleSpanExporter from the example section
Steps to reproduce
app.py
import tornado.httpclient # noqa: E402, I202
import tornado.httpserver # noqa: E402, I202
import tornado.ioloop # noqa: E402, I202
import tornado.web # noqa: E402, I202
from urls import url_patterns # noqa: E402, I202
APP_PORT = 80
SETTINGS = {
"debug": False,
"autoreload": True,
"cookie_secret": "<dummy>",
"template_path": "<dummy>",
"static_path": "<dummy>",
"xsrf_cookies": False
}
class App(tornado.web.Application):
"""App."""
def __init__(self):
"""Init."""
tornado.web.Application.__init__(self, url_patterns, **SETTINGS)
def main():
"""Main Method."""
TornadoInstrumentor().instrument()
app = App()
http_server = tornado.httpserver.HTTPServer(app, idle_connection_timeout=180)
http_server.listen(APP_PORT)
io_loop = tornado.ioloop.IOLoop.instance()
tornado.httpclient.AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
io_loop.start()
main()
views.py
implement simple apis.
call an api and response is received by client but server raises Failed to detach context
ERROR:opentelemetry.context:Failed to detach context
What is the expected behavior?
no error
What is the actual behavior?
error
Additional context
doing a poc for tracing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied app.py reproduction with the versions listed in the issue and a simple API from views.py. Then inspect the Tornado instrumentation path involved in the request and response lifecycle. Done means the client receives the response without a “Failed to detach context” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100