Skip to content

Commit

Permalink
Add support for ASGI apis.
Browse files Browse the repository at this point in the history
  • Loading branch information
newrelic-opensource committed Aug 31, 2020
1 parent 1b021e1 commit be13182
Show file tree
Hide file tree
Showing 15 changed files with 2,380 additions and 54 deletions.
9 changes: 9 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ In the event that a required notice is missing or incorrect, please notify us
by e-mailing [[email protected]](mailto:[email protected]).


## [asgiref](https://pypi.org/project/asgiref/)

Copyright (c) Django Software Foundation and individual contributors.

Distributed under the following license(s):

* [The BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)


## [six](https://pypi.org/project/six)

Copyright (c) 2010-2013 Benjamin Peterson
Expand Down
15 changes: 15 additions & 0 deletions newrelic/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
WSGIApplicationWrapper as __WSGIApplicationWrapper,
wrap_wsgi_application as __wrap_wsgi_application)

try:
from newrelic.api.asgi_application import (
asgi_application as __asgi_application,
ASGIApplicationWrapper as __ASGIApplicationWrapper,
wrap_asgi_application as __wrap_asgi_application)
except SyntaxError:
def __asgi_application(*args, **kwargs):
pass

__ASGIApplicationWrapper = __asgi_application
__wrap_asgi_application = __asgi_application

from newrelic.api.web_transaction import (
WebTransaction as __WebTransaction,
web_transaction as __web_transaction,
Expand Down Expand Up @@ -258,6 +270,7 @@
current_trace_id = __wrap_api_call(__current_trace_id, 'current_trace_id')
current_span_id = __wrap_api_call(__current_span_id, 'current_span_id')
wsgi_application = __wsgi_application
asgi_application = __asgi_application
WebTransaction = __wrap_api_call(__WebTransaction,
'WebTransaction')
web_transaction = __wrap_api_call(__web_transaction,
Expand All @@ -268,6 +281,8 @@
'wrap_web_transaction')
WSGIApplicationWrapper = __WSGIApplicationWrapper
wrap_wsgi_application = __wrap_wsgi_application
ASGIApplicationWrapper = __ASGIApplicationWrapper
wrap_asgi_application = __wrap_asgi_application
background_task = __wrap_api_call(__background_task,
'background_task')
BackgroundTask = __wrap_api_call(__BackgroundTask,
Expand Down
Loading

0 comments on commit be13182

Please sign in to comment.