jazzband / django-silk

Silky smooth profiling for Django
MIT License
4.42k stars 333 forks source link

Request: Custom label / names for requests #607

Open tony opened 1 year ago

tony commented 1 year ago

Assume #606, GraphQL requests aren't possible to distinguish at this point.

Sometimes a path has nuance to it, e.g. business logic inside the HttpRequest can be used to label the request so its not random

![image](https://user-images.githubusercontent.com/26336/196420009-5138cdee-b0e7-4a12-8c7c-e9353c1c328b.png)

Request model

1. New field: Custom label field

If there was a label / title to give requests for what to show in /silk/requests/ instead of request.path

2. New callback: In RequestModelFactory.construct_request_model()

This is to customize the contents of models.Request.

It will have accessed to to the django HttpRequest via self.request to fetch any necessary metadata and write a label

Why not SILKY_INTERCEPT_FUNC?

Why not view_name?

The user has their own specific logic in which they'd separate out a request of the same path. GraphQL being a perfect example.

But you can do it with profiling

Profiling is different feature in django-silk (as of 5.0.1). Yes, you can use a silk_profile(name='name') decorator, but that's not a delineating a different request.