Skip to content

Commit

Permalink
Fix crash in route wrappers for Starlette 0.19.1 (#527)
Browse files Browse the repository at this point in the history
* Fix crash in route wrappers for starlette 0.19.1

Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com>
Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com>

* [Mega-Linter] Apply linters fixes

* Bump Tests

Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com>
Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com>
Co-authored-by: TimPansino <TimPansino@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 26, 2022
1 parent e152949 commit 5890920
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion newrelic/hooks/framework_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@ def bind_add_exception_handler(exc_class_or_status_code, handler, *args, **kwarg

def wrap_route(wrapped, instance, args, kwargs):
path, endpoint, args, kwargs = bind_endpoint(*args, **kwargs)
endpoint = route_naming_wrapper(FunctionTraceWrapper(endpoint))
endpoint = FunctionTraceWrapper(endpoint)

# Starlette name detection gets a bit confused with our wrappers
# so the get_name function should be called and the result should
# be cached on the wrapper.
try:
if not hasattr(endpoint, "__name__"):
from starlette.routing import get_name

endpoint.__name__ = get_name(endpoint.__wrapped__)
except Exception:
pass

endpoint = route_naming_wrapper(endpoint)
return wrapped(path, endpoint, *args, **kwargs)


Expand Down

0 comments on commit 5890920

Please sign in to comment.