You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/26 16:32:13 UTC

git commit: [#5998] ticket:315 Set NewRelic transaction name to actual controller name

Updated Branches:
  refs/heads/master 8ade72f0c -> c01c95eb1


[#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/master
Commit: c01c95eb13ada2d6665906642d77254ebe2a8d96
Parents: 8ade72f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Apr 19 09:08:21 2013 +0000
Committer: Cory Johns <cj...@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