drf-api-tracking
drf-api-tracking copied to clipboard
Log custom headers
Some requests might include additional, useful information about the client in some custom HTTP header, say X-Client-Name and X-Client-Version. There is no way to currently get that information.
I see two main approaches, both based on a JSON field to store headers (that would restrict this feature to the DB backends that support JSON fields, but it's already been suggested to use them in #2):
- Should we log all headers? This could significantly increase the size of a log entry.
- Should we allow the user to specify which headers he's interested in? In settings? This requires some setup but allows to target only useful headers, so that's my favorite approach so far.
I think having an option in settings to determine a list of headers to store.
Also I think storing this data is a json field is the most flexible. Django 3.1 now supports JSONfields for all db backends: https://docs.djangoproject.com/en/3.1/releases/3.1/#jsonfield-for-all-supported-database-backends
+1
It's realy important feature.