Coder Social home page Coder Social logo

Comments (3)

korfuri avatar korfuri commented on June 12, 2024

https://github.com/korfuri/django-prometheus/blob/master/django_prometheus/middleware.py#L120 occurs in process_view which is run after the resolver_match is set (because URL processing needs to happen before view processing). We have a test covering this metric at https://github.com/korfuri/django-prometheus/blob/master/tests/end2end/testapp/test_middleware.py#L38.

If you are running a system where this metric is never incremented, please reopen and let me know about your setup. Thanks a lot!

from django-prometheus.

jtallieu avatar jtallieu commented on June 12, 2024

HI, thank you for getting back to me. We are using gevent and gevent.WSGIServer with Django 1.4.18. When I add the following line in a middleware.process_view method:

class ProfilerMiddleware(object):

    def process_view(self, request, view_func, view_args, view_kwargs):
        print "************", request.resolver_match.view_name
        ...

I see the following output:

Traceback (most recent call last):
  File "/home/jtallieu/.een/gateway/lib/python2.7/site-packages/django/core/handlers/base.py", line 103, in get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/home/jtallieu/.een/gateway/lib/python2.7/site-packages/videobank/core/profiler.py", line 52, in process_view
    print "************", request.resolver_match.view_name
AttributeError: 'WSGIRequest' object has no attribute 'resolver_match'

from django-prometheus.

korfuri avatar korfuri commented on June 12, 2024

This appears to depend on the version of Django in use. Can you try with a supported Django version? 1.4 is quite old and was EOL'd in October 2015. The next version of django-prometheus will drop support for Django versions < 1.8.

from django-prometheus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.