def _set_django_attributes(tracer, request):
    """Set the django related attributes."""
    django_user = getattr(request, 'user', None)
    if django_user is None:
        return
    user_id = django_user.pk
    user_name = django_user.get_username()
    if user_id is not None:
        tracer.add_attribute_to_current_span('/django/user/id', str(user_id))
    if user_name is not None:
        tracer.add_attribute_to_current_span('/django/user/name', user_name)
