Created
November 25, 2014 23:01
-
-
Save amol-/c443ebb02fe2bf514e70 to your computer and use it in GitHub Desktop.
AppEnlight TurboGears2
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
TurboGears2 exception logging and performance monitoring | |
======================================================== | |
Approx. integration time: **2 minutes** | |
WSGI middleware is the most common way to use App Enlight with your web application written in TurboGears2 web framework. | |
Installation and Setup | |
---------------------- | |
Install ``appenlight_client`` using pip:: | |
pip install appenlight-client | |
Next you want to ensure that the AppEnlight middleware is in place and that routing informations are correctly reported. | |
To do so edit ``config/app_cfg.py``:: | |
class AppEnlightSupport(object): | |
def __call__(self): | |
from tg import hooks | |
hooks.register('before_config', self.enable_middleware) | |
hooks.wrap_controller(self.enable_controller_wrapper) | |
def enable_middleware(self, app): | |
from tg import config | |
from appenlight_client import make_appenlight_middleware | |
return make_appenlight_middleware(app, config._current_obj()) | |
def enable_controller_wrapper(self, next_caller): | |
from tg import request | |
from appenlight_client.utils import fullyQualifiedName | |
def appenlight_app_wrapper(config, controller, remainder, params): | |
try: | |
controller_repr = fullyQualifiedName(controller) | |
except: | |
controller_repr = repr(controller) | |
request.environ['appenlight.view_name'] = controller_repr | |
return next_caller(config, controller, remainder, params) | |
return appenlight_app_wrapper | |
from tg.configuration import milestones | |
milestones.config_ready.register(AppEnlightSupport()) | |
Now run your application providing ``APPENLIGHT_KEY/APPENLIGHT_INI`` environment variable or you can add ``appenlight.api_key`` to your TurboGears2 .ini config file instead:: | |
appenlight.api_key = YOUR_PRIVATE_KEY | |
# or use path ini file if you want to provide separate configuration | |
appenlight.config_path = %(here)s/appenlight.ini | |
You can now run your instrumented application. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment