def trace(self, *attributes):
def decorator(f):<EOL><INDENT>def wrapper(*args, **kwargs):<EOL><INDENT>if self._trace_all_requests:<EOL><INDENT>return f(*args, **kwargs)<EOL><DEDENT>self._before_request_fn(list(attributes))<EOL>try:<EOL><INDENT>r = f(*args, **kwargs)<EOL>self._after_request_fn()<EOL><DEDENT>except Exception as e:<EOL><INDENT>self._after_request_fn(error=e)<EOL>raise<EOL><DEDENT>self._after_request_fn()<EOL>return r<EOL><DEDENT>wrapper.__name__ = f.__name__<EOL>return wrapper<EOL><DEDENT>return decorator<EOL>
Function decorator that traces functions

NOTE: Must be placed after the @app.route decorator

@param attributes any number of flask.Request attributes
(strings) to be set as tags on the created span