-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from instana/better_faster_stronger_flask
Better, faster, stronger Flask initialization
- Loading branch information
Showing
8 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
from __future__ import print_function | ||
from instana import wsgi | ||
from flask.cli import ScriptInfo | ||
import wrapt | ||
import os | ||
|
||
|
||
def wrap_load_app(func): | ||
def wrapper(self, *args): | ||
app = func(self, *args) | ||
app.wsgi_app = wsgi.iWSGIMiddleware(app.wsgi_app) | ||
return app | ||
return wrapper | ||
def wrapper(wrapped, instance, args, kwargs): | ||
rv = wrapped(*args, **kwargs) | ||
instance.wsgi_app = wsgi.iWSGIMiddleware(instance.wsgi_app) | ||
return rv | ||
|
||
|
||
def hook(module): | ||
""" Hook method to install the Instana middleware into Flask """ | ||
ScriptInfo.load_app = wrap_load_app(ScriptInfo.load_app) | ||
if "INSTANA_DEV" in os.environ: | ||
print("==============================================================") | ||
print("Instana: Running flask hook") | ||
print("==============================================================") | ||
wrapt.wrap_function_wrapper('flask', 'Flask.__init__', wrapper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
HTTP_CLIENT = "g.hc" | ||
HTTP_SERVER = "g.http" | ||
|
||
class InstanaSpan(object): | ||
t = 0 | ||
p = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters