incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [07/12] git commit: [#5998] ticket:315 Set NewRelic transaction name to actual controller name
Date Fri, 26 Apr 2013 14:53:11 GMT
[#5998] ticket:315 Set NewRelic transaction name to actual controller name


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c01c95eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c01c95eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c01c95eb

Branch: refs/heads/cj/5655
Commit: c01c95eb13ada2d6665906642d77254ebe2a8d96
Parents: 8ade72f
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Apr 19 09:08:21 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Apr 26 14:31:48 2013 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py |    2 ++
 Allura/allura/lib/patches.py       |   12 ++++++++++++
 Allura/development.ini             |    2 ++
 3 files changed, 16 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c01c95eb/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 805a9b9..09849a1 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -84,6 +84,8 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
         [pkg_resources.resource_filename('allura', 'etc/mime.types')]
         + mimetypes.knownfiles)
     patches.apply()
+    if asbool(app_conf.get('newrelic')):
+        patches.newrelic()
     # Configure MongoDB
     ming.configure(**app_conf)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c01c95eb/Allura/allura/lib/patches.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/patches.py b/Allura/allura/lib/patches.py
index 560e2f4..adbc4bc 100644
--- a/Allura/allura/lib/patches.py
+++ b/Allura/allura/lib/patches.py
@@ -72,3 +72,15 @@ def apply():
         if request.method == 'GET' and not(request.path.endswith('/')) and not(request.response_type)
and len(request.params)==0:
             raise webob.exc.HTTPMovedPermanently(location=request.url+'/')
         return func(*args, **kwargs)
+
+
+def newrelic():
+    old_call = tg.controllers.DecoratedController._call
+
+    @h.monkeypatch(tg.controllers.DecoratedController,
+                   tg.controllers.decoratedcontroller.DecoratedController)
+    def _call(self, controller, *args, **kwargs):
+        '''Set NewRelic transaction name to actual controller name'''
+        import newrelic.agent
+        newrelic.agent.set_transaction_name(newrelic.agent.callable_name(controller))
+        return old_call(self, controller, *args, **kwargs)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c01c95eb/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 761876b..9cb99c3 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -49,6 +49,8 @@ use_queue = true
 
 base_url = http://localhost:8080
 
+# newrelic = true
+
 #lang = ru
 cache_dir = %(here)s/data
 beaker.session.key = allura


Mime
View raw message