in libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/django/middleware.py [0:0]
def process_view(self, request, view_func, view_args, view_kwargs):
if not hasattr(request, "appinsights"):
return None
data = request.appinsights.request
context = request.appinsights.context
# Operation name is the method + url by default (set in __call__),
# If use_view_name is set, then we'll look up the name of the view.
if self._settings.use_view_name:
mod = inspect.getmodule(view_func)
if hasattr(view_func, "__name__"):
name = view_func.__name__
elif hasattr(view_func, "__class__") and hasattr(
view_func.__class__, "__name__"
):
name = view_func.__class__.__name__
else:
name = "<unknown>"
if mod:
opname = "%s %s.%s" % (data.http_method, mod.__name__, name)
else:
opname = "%s %s" % (data.http_method, name)
data.name = opname
context.operation.name = opname
# Populate the properties with view arguments
if self._settings.record_view_arguments:
for i, arg in enumerate(view_args):
data.properties["view_arg_" + str(i)] = arg_to_str(arg)
for k, v in view_kwargs.items(): # pylint: disable=invalid-name
data.properties["view_arg_" + k] = arg_to_str(v)
return None