Search code examples
pythonfastapinewrelic

Newrelic for FastApi


I use this command in docker compose: newrelic-admin run-program gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000

but after running, I encountered with following error:

(14/ThreadPoolExecutor-0_0) newrelic.core.trace_cache ERROR - Runtime instrumentation error. An active trace already exists in the cache on thread_id 281472746332640. Report this issue to New Relic support.

How can I fix it?! Thanks


Solution

  • I initialized newrelic.ini config in main.py. It works and the errors were fixed:

    import newrelic.agent
    
    newrelic.agent.initialize('newrelic.ini')