Better view names for DRF/Tastpie transactions
Django Rest Framework ViewSets will show up as a single transaction even though a ViewSet might have different methods that provide different functionality.
any updates on this?
:+1:
FYI there is a workaround here: https://gist.github.com/piquadrat/b494bd4b368ea4095dad3b629333ae58
@santiagomalter the link is now broken, do you have any other info on the workaround? We are facing the same issue
This is the one: https://gist.github.com/beniwohli/b494bd4b368ea4095dad3b629333ae58
@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