opbeat / opbeat_python

Python agent for Opbeat.
Other
90 stars 39 forks source link

Differentiate between ajax and normal requests for performance overview #84

Open mvantellingen opened 8 years ago

mvantellingen commented 8 years ago

It would be cool to split the performance overview in regular requests and ajax requests. We can achieve this ourselves by appending '_ajax' to the view name if request.is_ajax is true (in Django) via monkeypatching.

roncohen commented 8 years ago

@mvantellingen thank you for this feature request. This could certainly be interesting. We've also considered differentiating different HTTP method requests to the same views. E.g. POST /api/users different from GET /api/user.

When we take another look at it, I will also be taking this issue into consideration. Thanks again!

santiagomalter commented 7 years ago

Hello @roncohen, I am particularly interested by the feature you mentioned, being able to distinguish HTTP requests served from the same django class based view. (GET /api/user/ vs POST /api/user/)

Is there any plan regarding this? Thanks!

And +1 for ajax vs. normal requests.

beniwohli commented 7 years ago

@santiagomalter we shipped an implementation to distinguish between different http methods some months ago. If you don't see it, you might need to update your Opbeat module :)

santiagomalter commented 7 years ago

@piquadrat Thanks for the quick reply :) Indeed, my bad, I was trying to express something slightly different.

In a Django context, we have multiple API endpoints served by the same class based view, let's say:

GET /api/users/
GET /api/users/1/
GET /api/users/1/something/

They all appear under the same "view", but performance can be totally different so it would make sense to use to distinguish them and if I'm correct it's not possible right now, because everything is aggregated under the same HTTP Method + View.

But maybe it is too specific and you have no plan to add this feature? Solution could be to group requests by HTTP method + URL?

Thank you for your awesome work anyway :)

beniwohli commented 7 years ago

@santiagomalter are you using a framework like tastypie or Django Rest Framework or custom class based views? For the latter, and if you use viewsets, there's this workaround: https://gist.github.com/piquadrat/b494bd4b368ea4095dad3b629333ae58

santiagomalter commented 7 years ago

Indeed, we are using Django Rest Framework. Thank you for the workaround, exactly what I was looking for, i'll implement that :)