Middleware

This module contains middleware to ensure best practices of DRF and other endpoints..

class RequestMetricsMiddleware

Adds various request related metrics.

Possible metrics include:
request_auth_type: Example values include: no-user, unauthenticated,
jwt, bearer, other-token-type, or session-or-unknown

request_client_name: The client name from edx-rest-api-client calls. request_referer request_user_agent: The user agent string from the request header. request_user_id: The user id of the request user.

This middleware is dependent on the RequestCacheMiddleware. You must include this middleware later. For example:

MIDDLEWARE_CLASSES = (
    'edx_django_utils.cache.middleware.RequestCacheMiddleware',
    'edx_rest_framework_extensions.middleware.RequestMetricsMiddleware',
)

This middleware should also appear after any authentication middleware.

process_response(request, response)

Add metrics for various details of the request.