[Answered ]-See decorated Django view names in NewRelic

1👍

I work for New Relic, and we’re aware of this issue. To avoid it, you can use the ‘wraps()’ decorator from the standard library ‘functools’ module to wrap the inner decorator function, like this:

import functools

def decorator(f):
    @functools.wraps(f)
    def _decorator():
        f()
    return _decorator

@decorator
def foo():
    pass

See this doc for more details: https://newrelic.com/docs/python/python-tips-and-tricks#decorators_and_introspection

1👍

Have a look at functools.wrap this will make sure the __name__ attribute of the decorated function is not the name of the decorator (but that it keeps the name of the inner function)

Leave a comment