Permalink
Browse files

Better fix for stats remote.ip

git-svn-id: http://svn.cherrypy.org/trunk@2761 e1d34091-3ce9-0310-8e96-997e60db3bd5
  • Loading branch information...
1 parent ed15c05 commit e4f08ae1760913d9b8adc046845cd08226579658 fumanchu committed Feb 24, 2011
Showing with 2 additions and 9 deletions.
  1. +2 −9 cherrypy/lib/cpstats.py
@@ -295,9 +295,6 @@ def _setup(self):
if appstats.get('Enabled', False):
cherrypy.Tool._setup(self)
self.record_start()
- cherrypy.request.hooks.attach('before_request_body',
- self.record_resource,
- priority=35)
def record_start(self):
"""Record the beginning of a request."""
@@ -313,19 +310,15 @@ def record_start(self):
appstats['Requests'][threading._get_ident()] = {
'Bytes Read': None,
'Bytes Written': None,
- 'Client': '%s:%s' % (r.ip, r.port),
+ # Use a lambda so the ip gets updated by tools.proxy later
+ 'Client': lambda s: '%s:%s' % (r.ip, r.port),
'End Time': None,
'Processing Time': proc_time,
'Request-Line': request.request_line,
'Response Status': None,
'Start Time': time.time(),
}
- def record_resource(self, debug=False):
- w = appstats['Requests'][threading._get_ident()]
- r = cherrypy.serving.request.remote
- w['Client'] = '%s:%s' % (r.ip, r.port)
-
def record_stop(self, uriset=None, slow_queries=1.0, slow_queries_count=100,
debug=False, **kwargs):
"""Record the end of a request."""

0 comments on commit e4f08ae

Please sign in to comment.