moesif / moesifdjango Goto Github PK
View Code? Open in Web Editor NEWMiddleware for Python Django
Home Page: https://www.moesif.com
License: Other
Middleware for Python Django
Home Page: https://www.moesif.com
License: Other
Currently using Python 3.7/3.8 with Django 3.
Is there any plan to support these any time soon / known workarounds?
I am currently trying to integrate and am stuck in "No data received yet. It may take a few moments...."
After installing the Moesif middleware, I got the following polluting my logs every 5 seconds:
INFO 2021-02-09 18:50:49,865 base 4 139721478100736 Running job "Schedule events batch job every 5 second (trigger: interval[0:00:05], next run at: 2021-02-09 18:50:49 UTC)" (scheduled at 2021-02-09 18:50:49.858046+00:00)
INFO 2021-02-09 18:50:50,228 base 4 139721478100736 Job "Schedule events batch job every 5 second (trigger: interval[0:00:05], next run at: 2021-02-09 18:50:54 UTC)" executed successfully
It also appears during interactive sessions.
I believe the following line is overriding the configuration of other loggers:
https://github.com/Moesif/moesifdjango/blob/master/moesifdjango/middleware.py#L33
Hello,
I am trying to upload an image to a post request and I have the following error.
It seems like something is wrong with the middleware in line 66 when the copy.copy happens.
Looking at it, but also sharing it here in order to investigate it further..
Environment:
Request Method: POST
Request URL: http://localhost:8000/v1/s3direct/get_upload_params/
Django Version: 1.11.7
Python Version: 2.7.10
Installed Applications:
['django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.postgres',
'orfium',
'django.contrib.admin',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django.contrib.sitemaps',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.instagram',
'allauth.socialaccount.providers.soundcloud',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.spotify',
'django.contrib.auth',
'storages',
'admin_reorder',
'side_packages.signals',
'side_packages.s3direct',
'side_packages.braintree',
'oauth2_provider',
'haystack',
'playlog',
'top_charts',
'labels',
'upload_manager',
'orfium_impersonation',
'impersonate',
'django_filters',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
'rest_auth',
'rest_auth.registration',
'api',
'corsheaders',
'celery_haystack',
'shopping_cart',
'rest_framework_cache',
'cacheops',
'chat']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'api.authentication.middleware.OAuth2TokenMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.security.SecurityMiddleware',
'moesifdjango.middleware.moesif_middleware',
'hirefire.contrib.django.middleware.HireFireMiddleware']
Traceback:
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/moesifdjango/middleware.py" in middleware
66. raw_request_body = copy.copy(request.body)
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/django/http/request.py" in body
264. raise RawPostDataException("You cannot access body after reading from request's data stream")
Exception Type: RawPostDataException at /v1/s3direct/get_upload_params/
Exception Value: You cannot access body after reading from request's data stream
Hello, I get the following error.
Any ideas?
I am using python 2.7.11 and django 1.11
Thank you in advance,
Michael.
File "/Users/apilama/Desktop/projects/repos/orfium-django/orfium_project/wsgi.py", line 27, in <module>
application = get_wsgi_application()
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 151, in __init__
self.load_middleware()
File "/Users/apilama/Desktop/projects/venvs/orfium/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 58, in load_middleware
mw_instance = mw_class()
TypeError: moesif_middleware() takes exactly 1 argument (0 given)
Hi there!
I want to set up moesif to my Graphql API, but I faced some issues:
Unauthorized access getting application configuration. Please check your Appplication Id.
Response bytes body
ERROR django.request:log.py:228 Internal Server Error: /graphql/
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/moesifdjango/middleware.py", line 345, in __call__
self.sampling_percentage = self.app_config.get_sampling_percentage(self.config, username, company_id)
File "/usr/local/lib/python3.7/site-packages/moesifdjango/app_config.py", line 32, in get_sampling_percentage
config_body = json.loads(config.raw_body)
AttributeError: 'NoneType' object has no attribute 'raw_body'
can you please help!
Thank you!!
Django 3.2 use HttpResponse.headers in place of ._headers. update line https://github.com/Moesif/moesifdjango/blob/master/moesifdjango/middleware.py#L191
Error with Django 3.2+
2021-06-26T09:50:48.722684+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/moesifdjango/middleware.py", line 191, in call
2021-06-26T09:50:48.722686+00:00 app[web.1]: response._headers["x-moesif-transaction-id"] = ("X-Moesif-Transaction-Id", transaction_id)
2021-06-26T09:50:48.722687+00:00 app[web.1]: AttributeError: 'HttpResponse' object has no attribute '_headers'
Downgrading to Django 3.1.12 works
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.