Unable to run on uwsgi
See original GitHub issueDescribe the bug: Middleware not sending data to the server
To Reproduce
- Setup a django project (2.0) with python 3.5
- Configure elastic-apm: Service name is set, good job!
- optional SECRET_TOKEN not set
SERVER_URL http://blablabla.com looks fine
DEBUG mode is disabled! Looking good!
Tracing middleware is configured! Awesome!
Looks like everything should be ready!
Expected behavior: Metrics and transactions should be recorded in kibana dashboard. The test (python manage.py test) error is recorded successfully.
Environment (please complete the following information)
- OS: Ubuntu 16.04
- Python version: 3.5
- Framework and version [e.g. Django 2.1]: 2.0
- APM Server version: 6.7.0
- Agent version: 4.2.1
Additional context
Add any other context about the problem here.
- Agent config options
Nothing out of the ordinary. In my settings, a dictionary with SERVER_URL (http) and SERVICE_NAME
- `requirements.txt`:Click to expand
```
amqp==2.4.2 argon2-cffi==19.1.0 Babel==2.6.0 billiard==3.5.0.5 boto3==1.9.114 botocore==1.12.114 celery==4.2.2 certifi==2019.3.9 cffi==1.12.2 chardet==3.0.4 Collectfast==0.6.2 coreapi==2.3.3 coreschema==0.0.4 defusedxml==0.5.0 Django==2.0.13 django-allauth==0.38.0 django-anymail==5.0 django-crispy-forms==1.7.2 django-environ==0.4.5 django-model-utils==3.1.2 django-redis==4.10.0 django-storages==1.7.1 djangorestframework==3.9.1 docutils==0.14 elastic-apm==4.2.1 flower==0.9.2 gunicorn==19.9.0 idna==2.8 itypes==1.1.0 Jinja2==2.10 jmespath==0.9.4 kombu==4.3.0 MarkupSafe==1.1.1 oauthlib==3.0.1 Pillow==5.4.1 pkg-resources==0.0.0 psutil==5.6.1 psycopg2==2.7.4 pycparser==2.19 python-dateutil==2.8.0 python-slugify==2.0.1 python3-openid==3.1.0 pytz==2018.9 pyzmq==16.0.4 redis==2.10.6 requests==2.21.0 requests-oauthlib==1.2.0 s3transfer==0.2.0 six==1.12.0 tornado==4.5.3 Unidecode==1.0.23 uritemplate==3.0.0 urllib3==1.24.1 vine==1.3.0 ```
Edit: I was able to send data to the apm-server using django’s dev server, so the issue is not there. I am trying to check if there is an issue with uwsgi. I enabled threads, as mentioned in the docs, but still no luck: Thu Mar 28 02:16:41 2019 - Python main interpreter initialized at 0x1f7f750 Thu Mar 28 02:16:41 2019 - python threads support enabled Thu Mar 28 02:16:41 2019 - your server socket listen backlog is limited to 100 connections Thu Mar 28 02:16:41 2019 - your mercy for graceful operations on workers is 60 seconds Thu Mar 28 02:16:41 2019 - mapped 166144 bytes (162 KB) for 2 cores Thu Mar 28 02:16:41 2019 - *** Operational MODE: threaded ***
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
I am having the same problem as above (not fixed by installing
uwsgidecorators
or bylazy-apps=true
), which I put down to this issue.I’ve just redeployed using
elastic-apm==5.4.1
(I’mdjango==1.11.28
and still havelazy-apps=true
,enable-threads = true
, andsingle-interpreter = true
), but still have the same issue.I can see only the first few requests to my health-check endpoint in APM, and then nothing. The test error from
manage.py
gets through fine, as in the original report. I’ll wait for someone else to confirm before re-opening in case it’s me doing something else wrong.Just a quick test, follow my…
api.py
app.config[‘ELASTIC_APM’] = { ‘SERVICE_NAME’: __service_name, # ‘SECRET_TOKEN’: ‘’, ‘SERVER_URL’: os.environ.get(‘ELASTIC_APM_URL’, ‘http://localhost:8200’) } apm = ElasticAPM(app)
wsgi.py
import os
from elasticapm.handlers.logging import LoggingHandler from api import app, apm
if name == ‘main’: # Create a logging handler and attach it. handler = LoggingHandler(client=apm.client) # handler.setLevel(logging.WARN) app.logger.addHandler(handler) app.run( host = os.environ.get(“GATEWAYAPI_HOST”, “localhost”), port = os.environ.get(“GATEWAYAPI_PORT”, “5000”), debug = False, threaded = True )
wsgi.ini
[uwsgi] project = gateway_api module = wsgi:app master = true processes = 5 http = 0.0.0.0:5000 die-on-term = true enable-threads = true lazy-apps = true
It works for me! I hope to help someone! =]