You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importconnexionapp=connexion.App( __name__, specification_dir='.')
...
# setup Datadog integrationddtrace.tracer.configure(hostname=app.app.config.DD_APM_HOST, port=8126)
ddtrace.tracer.set_tags({'env': 'the-env')})
ddtrace.config.flask['analytics_enabled'] =Trueddtrace.config.flask['trace_signals'] =Falseddtrace.patch_all(logging=True)
# we have also tried adding the tracing middleware here# app.add_middleware(TraceMiddleware)# we also tried patching here insteadddtrace.patch_all(logging=True, starlette=True)
This was not happening when we were using the previous version of Connexion (connexion = "2.14.2"), Flask and dd-trace (ddtrace = "2.7.3")
Solutions Tried
One of the many things I have tried was to use the TraceMiddleware as follows and, patching the application in different places.
importconnexionfromddtrace.contrib.asgiimportTraceMiddlewarefromddtrace.contrib.starletteimportpatchpatch() # patching hereapp=connexion.App( __name__, specification_dir='.')
# patch() # or patching hereapp.add_middleware(TraceMiddleware)
# patch() # or patching here
Via the logs I can see that starlette has been patched correctly
Configured ddtrace instrumentation for 59 integration(s). The following modules have been patched: aioredis,aiomysql,aredis,asyncio,boto,botocore,bottle,cassandra,celery,consul,django,dramatiq,elasticsearch,algoliasearch,futures,gevent,graphql,grpc,httpx,kafka,mongoengine,mysql,mysqldb,pymysql,mariadb,psycopg,pylibmc,pymemcache,pymongo,redis,rediscluster,requests,rq,sanic,sqlite3,aiohttp,aiohttp_jinja2,aiopg,vertica,molten,jinja2,mako,flask,flask_login,starlette,falcon,pyramid,logging,pynamodb,pyodbc,fastapi,dogpile_cache,yaaredis,asyncpg,aws_lambda,openai,langchain,subprocess,unittest
I have followed the docs for dd-trace integration but I still can't make it work.
The application does work well. Meaning that I'm able to make requests to the API it implements.
Additional info:
The most important and relevant would libraries that we need are:
We use the datadog lambda layer without issue at work, which AFAIK, redirects STDOUT to datadog.
From the code I am reading here; it looks like DataDog is trying to manually instrument the framework, which I think means it needs to be instantiated prior to the framework code.
Note that your minimal example with starlette, you import and initialise dd_agent before Starlette, but in your example here it comes after.
I'm also not seeing a datadog API key anywhere, even referenced by environment. Can you check that you have either DD_AGENT or DD_API_KEY set in the environment and that the values are correct?
Description
Running the latest version of the Connexion framework with a Flask application I get the following warning while trying to log messages to Datadog:
datadog context not present in ASGI request scope, trace middleware may be missing
This warning effectively means that we don't have tracing enabled for our application.
Expected behaviour
We expect not to see the warning message and to have tracing enabled for the underlying Flask application.
Actual behaviour
We get the following warning and DD traces are disabled.
Steps to reproduce
We create the application as follows:
Then, the application runs via
docker-compose
:CMD ["gunicorn", "-c", "gunicorn.conf.py", "-k", "uvicorn.workers.UvicornWorker", "myproject.__main__:create_app()"]
This was not happening when we were using the previous version of Connexion (
connexion = "2.14.2"
), Flask and dd-trace (ddtrace = "2.7.3"
)Solutions Tried
One of the many things I have tried was to use the
TraceMiddleware
as follows and, patching the application in different places.Via the logs I can see that
starlette
has been patched correctlyConfigured ddtrace instrumentation for 59 integration(s). The following modules have been patched: aioredis,aiomysql,aredis,asyncio,boto,botocore,bottle,cassandra,celery,consul,django,dramatiq,elasticsearch,algoliasearch,futures,gevent,graphql,grpc,httpx,kafka,mongoengine,mysql,mysqldb,pymysql,mariadb,psycopg,pylibmc,pymemcache,pymongo,redis,rediscluster,requests,rq,sanic,sqlite3,aiohttp,aiohttp_jinja2,aiopg,vertica,molten,jinja2,mako,flask,flask_login,starlette,falcon,pyramid,logging,pynamodb,pyodbc,fastapi,dogpile_cache,yaaredis,asyncpg,aws_lambda,openai,langchain,subprocess,unittest
I have followed the docs for dd-trace integration but I still can't make it work.
The application does work well. Meaning that I'm able to make requests to the API it implements.
Additional info:
The most important and relevant would libraries that we need are:
Output of the commands:
python --version
pip show connexion | grep "^Version\:"
Does anyone know how to solve this issue? Have anyone else run into the same problem? Thanks.
The text was updated successfully, but these errors were encountered: