APM agent not sending event requests to the APM server with gunicorn wsgi.
See original GitHub issueI’m running a flask application and everything works fine if I’m running the application in dev environment i.e. directly from command line or my IDE aka Pycharm.
But when I run the same app on production via gunicorn, it only sends agents
requests and no events
requests so in APM in kibana, no service shows up.
Reproduction steps:
- Create a basic flask app and call
client.begin_transaction
andclient.end_transaction
before and after each request so as to log time of each request. - Run the app via
gunicorn
. - Make a request to the app via browser or postman.
Expected behavior:
The apm server logs show /intake/v2/events
requests as well as /config/v1/agents
request.
Environment/
- OS: macOS
- Python version: 3.5
- Framework and version: Flask 1.0.2
- Elasticsearch version: 7.4.1
- Kibana version: 7.4.1
- APM Server version: 7.4.1
- Agent version: 5.2.2
Additional context
I’m running Elasticsearch on 0.0.0.0:9200, Kibana on 0.0.0.0:5601, and APM on 0.0.0.0.8200.
A curl
request to all these shows the desired result.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
APM not showing data in Kibana when running app ...
No data is being shown in Kibana UI or APM server logs if I run the app in production using gunicorn WSGI but...
Read more >Python agent not uploading data from gunicorn. ...
I'm curious to know if you have the app actually connected to the APM? If not, you might want to check this portion...
Read more >django - Elastic Apm python agent connection problem
On my APM server, I'm not receiving any requests from my agent. I checked the APM server log files. django · elasticsearch ·...
Read more >NGINX 502 Bad Gateway: Gunicorn
NGINX will return a 502 Bad Gateway error if it can't successfully proxy a request to Gunicorn or if Gunicorn fails to respond....
Read more >Advanced Usage — ddtrace documentation - Read the Docs
If the Datadog Agent is on a separate host from your application, you can modify the default ddtrace.tracer object to utilize another hostname...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the update. Forking models for concurrency have long given the agent issues, as we lose the background threads on fork. Rather than trying to come up with a solution for each implementation, we’re going to focus on #636 so that we will automatically detect forks and re-create those background threads. This should fix the majority of issues like this one.
I can confirm that disabling preloading in gunicorn fixes the issue - transactions are now properly saved.
We’re using this docker CMD with no configuration file:
I also had to switch the transaction type to
request
in the APM UI: