-
Notifications
You must be signed in to change notification settings - Fork 457
Description
Summary of problem
I have been trying to debug an issue in a FastAPI/OpenAI application where, upon calls to OpenAI (Creating embeddings for example), or for example the following
@router.get("/ask-debug")
def ask_debug():
from langchain.llms import OpenAI
llm = OpenAI(model_name="gpt-3.5-turbo-0613")
answer = llm("What is the capital of Ireland")
return answer
The container instantly dies around 90/95% of the time. The odd time it works but most of the time, the container just instantly gets killed the second the call to OpenAI is made.
No logs, no stack trace no nothing.
It took me a while to figure this out but, when I disabled ddtrace, e.g. replaced the
ENTRYPOINT ["ddtrace-run"]
CMD ["uvicorn", "app.main:app" , "--host", "0.0.0.0", "--port", "80", "--log-level", "trace"]
With
ENTRYPOINT ["uvicorn"]
CMD ["app.main:app" , "--host", "0.0.0.0", "--port", "80", "--log-level", "trace"]
Everything works fine, I can confirm this further because, my final solution was to re-enable ddtrace-run
but with this set in my Dockerfile
ENV DD_PATCH_MODULES=openai:false
So there is something very strange happening within the dd tracer when interacting with OpenAI
Which version of dd-trace-py are you using?
ddtrace==1.15.1
Which version of pip are you using?
pip 23.2.1
Which libraries and their versions are you using?
`pip freeze`
aiohttp==3.8.5 aiosignal==1.3.1 annotated-types==0.5.0 anyio==3.7.1 astroid==2.15.6 async-timeout==4.0.2 attrs==23.1.0 beautifulsoup4==4.12.2 black==23.3.0 blinker==1.6.2 boto3==1.28.2 botocore==1.31.19 Brotli==1.0.9 build==0.10.0 bytecode==0.14.2 cattrs==23.1.2 certifi==2023.7.22 cffi==1.15.1 cfgv==3.3.1 chardet==3.0.4 charset-normalizer==3.2.0 click==8.1.6 ConfigArgParse==1.7 cryptography==41.0.3 dataclasses-json==0.5.14 ddsketch==2.0.4 ddtrace==1.18.0 debugpy==1.6.5 Deprecated==1.2.14 dill==0.3.7 distlib==0.3.7 docopt==0.6.2 envier==0.4.0 et-xmlfile==1.1.0 faiss-cpu==1.7.4 fastapi==0.99.0 filelock==3.12.2 fire==0.5.0 flake8==6.1.0 Flask==2.3.2 Flask-BasicAuth==0.2.0 Flask-Cors==4.0.0 frozenlist==1.4.0 fsspec==2023.6.0 gevent==23.7.0 geventhttpclient==2.0.9 googletrans==4.0.0rc1 greenlet==2.0.2 h11==0.9.0 h2==3.2.0 hpack==3.0.0 hstspreload==2023.1.1 httpcore==0.9.1 httpx==0.13.3 huggingface-hub==0.16.4 hyperframe==5.2.0 identify==2.5.26 idna==2.10 importlib-metadata==6.8.0 iniconfig==2.0.0 isort==5.12.0 itsdangerous==2.1.2 Jinja2==3.1.2 jmespath==1.0.1 joblib==1.3.2 langchain==0.0.264 langsmith==0.0.19 lazy-object-proxy==1.9.0 locust==2.15.1 markdown-it-py==3.0.0 MarkupSafe==2.1.3 marshmallow==3.20.1 mccabe==0.7.0 mdurl==0.1.2 moto==4.1.12 mpmath==1.3.0 msgpack==1.0.5 multidict==6.0.4 mypy==1.4.1 mypy-extensions==1.0.0 mypy-protobuf==3.4.0 ndg-httpsclient==0.5.1 networkx==3.1 nlpcloud==1.1.44 nltk==3.8.1 nodeenv==1.8.0 numexpr==2.8.5 numpy==1.25.2 openai==0.23.0 openapi-schema-pydantic==1.2.4 openpyxl==3.1.2 opentelemetry-api==1.19.0 orjson==3.9.5 packaging==23.1 pandas==2.0.3 pandas-stubs==2.0.3.230814 pathspec==0.11.2 Pillow==10.0.0 pip-tools==7.2.0 platformdirs==3.10.0 pluggy==1.2.0 pre-commit==3.3.3 protobuf==4.23.4 psutil==5.9.5 pusher==3.3.2 pyasn1==0.5.0 pycodestyle==2.11.0 pycparser==2.21 pycryptodome==3.18.0 pydantic==1.10.12 pydantic_core==2.6.0 pyflakes==3.1.0 Pygments==2.16.1 pylint==2.17.4 pylint-protobuf==0.20.2 PyNaCl==1.5.0 pyOpenSSL==23.2.0 pyproject_hooks==1.0.0 pytest==7.4.0 pytest-mock==3.11.1 python-dateutil==2.8.2 python-dotenv==1.0.0 python-json-logger==2.0.7 pytz==2023.3 PyYAML==6.0.1 pyzmq==25.1.0 redis==4.6.0 regex==2023.8.8 requests==2.31.0 requests-toolbelt==1.0.0 responses==0.23.3 rfc3986==1.5.0 rich==13.5.2 roundrobin==0.0.4 s3transfer==0.6.1 safetensors==0.3.2 scikit-learn==1.3.0 scipy==1.11.2 sentence-transformers==2.2.2 sentencepiece==0.1.99 simpleaichat==0.2.0 six==1.16.0 sniffio==1.3.0 soupsieve==2.4.1 SQLAlchemy==2.0.19 sse-starlette==1.6.1 starlette==0.27.0 stomp.py==8.1.0 sympy==1.12 tenacity==8.2.2 termcolor==2.3.0 threadpoolctl==3.2.0 tiktoken==0.4.0 tokenizers==0.13.3 tomlkit==0.12.1 torch==2.0.1 torchvision==0.15.2 tqdm==4.66.1 transformers==4.31.0 types-protobuf==4.23.0.2 types-pytz==2023.3.0.1 types-PyYAML==6.0.12.11 types-requests==2.31.0.1 types-urllib3==1.26.25.14 typing-inspect==0.9.0 typing_extensions==4.7.1 tzdata==2023.3 urllib3==1.26.16 uvicorn==0.22.0 virtualenv==20.24.2 websocket-client==1.6.1 Werkzeug==2.3.6 wrapt==1.15.0 xmltodict==0.13.0 yarl==1.9.2 zipp==3.16.2 zope.event==5.0 zope.interface==6.0How can we reproduce your problem?
Create a fast api application with ddtracer running using openai, implement the endpoint I mentioned above.
What is the result that you get?
Container dies instantly with no logs or stack trace
What is the result that you expected?
The container does not die