Skip to content
This repository has been archived by the owner on Jun 11, 2018. It is now read-only.

Better view names for DRF/Tastpie transactions #62

Open
roncohen opened this issue Sep 14, 2015 · 6 comments
Open

Better view names for DRF/Tastpie transactions #62

roncohen opened this issue Sep 14, 2015 · 6 comments

Comments

@roncohen
Copy link
Contributor

Django Rest Framework ViewSets will show up as a single transaction even though a ViewSet might have different methods that provide different functionality.

@hurrba
Copy link

hurrba commented Nov 2, 2015

any updates on this?

@dizballanze
Copy link

👍

@santiagomalter
Copy link

FYI there is a workaround here: https://gist.github.com/piquadrat/b494bd4b368ea4095dad3b629333ae58

@sathoro
Copy link

sathoro commented Jul 25, 2017

@santiagomalter the link is now broken, do you have any other info on the workaround? We are facing the same issue

@jalvz
Copy link

jalvz commented Jul 26, 2017

@sathoro
Copy link

sathoro commented Jul 26, 2017

@jalvz Thanks! I ended up creating a more generic solution:

class OpbeatViewNameMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.get_response(request)

    def process_view(self, request, view_func, view_args, view_kwargs):
        if (
            hasattr(request, '_opbeat_view_func') and
            hasattr(request, 'resolver_match')
        ):
            if hasattr(view_func, '__name__'):
                view_name = view_func.__name__
            else:
                view_name = view_func.__class__.__name__

            url_name = request.resolver_match.url_name

            if url_name:
                request._opbeat_transaction_name = '%s %s' % (view_name, request.resolver_match.url_name)
            else:
                request._opbeat_transaction_name = view_name

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants