[Checkins] SVN: zc.zservertracelog/branches/1.1/ merged changes from trunk (r92458-92727).
Alex Smith
alex at zope.com
Fri Oct 31 09:57:30 EDT 2008
Log message for revision 92728:
merged changes from trunk (r92458-92727).
Changed:
U zc.zservertracelog/branches/1.1/CHANGES.txt
U zc.zservertracelog/branches/1.1/README.txt
U zc.zservertracelog/branches/1.1/setup.py
U zc.zservertracelog/branches/1.1/src/zc/zservertracelog/README.txt
U zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracelog.py
U zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracereport.py
-=-
Modified: zc.zservertracelog/branches/1.1/CHANGES.txt
===================================================================
--- zc.zservertracelog/branches/1.1/CHANGES.txt 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/CHANGES.txt 2008-10-31 13:57:29 UTC (rev 92728)
@@ -2,6 +2,19 @@
Changes
=========
+(unreleased)
+------------
+
+- fixed tracelog extension format so that it doesn't conflict with the Zope2
+ trace code for server shutdown.
+
+- added *summary-only* and *summary-lines* options to tracereport.
+
+- added shading of alternating rows in tracereport table output.
+
+- fixed a documentation error for loghandler configuration.
+
+
0.4 (2008-10-09)
----------------
Modified: zc.zservertracelog/branches/1.1/README.txt
===================================================================
--- zc.zservertracelog/branches/1.1/README.txt 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/README.txt 2008-10-31 13:57:29 UTC (rev 92728)
@@ -7,6 +7,10 @@
request. Each log entry starts with a record type, a request
identifier and the time. Some log records have additional data.
+
+ Trace Codes
+=============
+
- Request begins:
B -1214390740 2007-04-27T20:16:55 GET /
@@ -37,6 +41,10 @@
S 0 2007-04-27T20:24:29
+Tracelog extension records are prefixed with a '-':
+
+ - -1223774356 2008-09-12T15:51:05 zc.example.extension message
+
To create a trace log, include the zc.zservertracelog package in your
site ZCML configuration. Also, define a logger section in zope.conf::
@@ -50,11 +58,8 @@
</logfile>
</logger>
-
+
where, of course, you'll need to specify a log file path.
-
+
The analysis script, tracereport, can be used to analyze the trace
log. I recommend the html output option.
-
-
-
Modified: zc.zservertracelog/branches/1.1/setup.py
===================================================================
--- zc.zservertracelog/branches/1.1/setup.py 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/setup.py 2008-10-31 13:57:29 UTC (rev 92728)
@@ -27,7 +27,7 @@
setup(
name=name,
- version='1.0.0',
+ version='1.1.0dev',
url='http://pypi.python.org/pypi/' + name,
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
Modified: zc.zservertracelog/branches/1.1/src/zc/zservertracelog/README.txt
===================================================================
--- zc.zservertracelog/branches/1.1/src/zc/zservertracelog/README.txt 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/src/zc/zservertracelog/README.txt 2008-10-31 13:57:29 UTC (rev 92728)
@@ -192,6 +192,6 @@
B 21569456 2008-09-12T15:51:05 GET /test-req1
I 21569456 2008-09-12T15:51:05 0
C 21569456 2008-09-12T15:51:05
- X 21569456 2008-09-12T15:51:05 beep! beep!
+ - 21569456 2008-09-12T15:51:05 beep! beep!
A 21569456 2008-09-12T15:51:05 200 ?
E 21569456 2008-09-12T15:51:05
Modified: zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracelog.py
===================================================================
--- zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracelog.py 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracelog.py 2008-10-31 13:57:29 UTC (rev 92728)
@@ -32,7 +32,7 @@
return dt.replace(microsecond=0).isoformat()
-def _log(channel_id, trace_code='X', msg=None, timestamp=None):
+def _log(channel_id, trace_code='-', msg=None, timestamp=None):
if timestamp is None:
timestamp = datetime.datetime.now()
@@ -57,7 +57,7 @@
self.channel_id = channel_id
def log(self, msg=None):
- _log(self.channel_id, 'X', msg)
+ _log(self.channel_id, '-', msg)
class Parser(zope.server.http.httprequestparser.HTTPRequestParser):
Modified: zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracereport.py
===================================================================
--- zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracereport.py 2008-10-31 13:44:36 UTC (rev 92727)
+++ zc.zservertracelog/branches/1.1/src/zc/zservertracelog/tracereport.py 2008-10-31 13:57:29 UTC (rev 92728)
@@ -1,6 +1,7 @@
+#!/usr/local/bin/python2.4
##############################################################################
#
-# Copyright (c) 2006, 2008 Zope Corporation and Contributors.
+# Copyright (c) Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,9 +12,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Yet another lag analysis tool
-
-$Id$
+"""Yet another trace log analysis tool
"""
import datetime, optparse, sys
@@ -82,7 +81,7 @@
else:
m = .5 * (times[n/2]+times[n/2-1])
self.median = m
- self.mean = sum(times)/n
+ self.mean = float(sum(times))/n
self.impact = self.mean * (n+self.hangs)
return self.impact
@@ -108,6 +107,12 @@
print td(impact, n, times[0], m, self.mean, times[-1],
self.hangs)
+ def __add__(self, other):
+ result = Times()
+ result.times = self.times + other.times
+ result.hangs = self.hangs + other.hangs
+ return result
+
def parsedt(s):
date, time = s.split('T')
return datetime.datetime(*(
@@ -142,7 +147,11 @@
minutes_header = minutes_header_text
minutes_footer = minutes_footer_text
+ if options.summary_only:
+ print_app_requests = output_minute = lambda *a, **kw: None
+ minutes_footer = minutes_header = lambda *a, **kw: None
+
urls = {}
[file] = args
lmin = ldt = None
@@ -180,7 +189,8 @@
if min != lmin:
if lmin is not None:
- output_minute(lmin, requests, input, wait, apps, output, n, spr, spa)
+ output_minute(lmin, requests, input, wait, apps, output,
+ n, spr, spa)
if apps > options.apps:
print_app_requests(requests, dt,
options.old_requests,
@@ -207,9 +217,6 @@
if remove_prefix and request.url.startswith(remove_prefix):
request.url = request.url[len(remove_prefix):]
requests[rid] = request
- times = urls.get(request.url)
- if times is None:
- times = urls[request.url] = Times()
elif typ == 'I':
if rid in requests:
input -= 1
@@ -233,8 +240,12 @@
spr += request.total_seconds
spa += request.app_seconds
n += 1
- times = urls[request.url]
+ url = "%s -> %s" % (request.url, request.response)
+ times = urls.get(url)
+ if times is None:
+ times = urls[url] = Times()
times.finished(request)
+
elif typ in 'SX':
print_app_requests(requests, ldt,
options.old_requests,
@@ -256,12 +267,12 @@
minutes_footer()
- output_stats(urls)
+ output_stats(urls, lines=options.summary_lines)
if options.html:
print '</body></html>'
-def output_stats_text(urls):
+def output_stats_text(urls, lines):
print
print 'URL statistics:'
print " Impact count min median mean max hangs"
@@ -271,11 +282,15 @@
]
urls.sort()
urls.reverse()
+ line = 0
for (_, url, times) in urls:
if times.impact > 0 or times.hangs:
print times, url
+ line += 1
+ if line > lines:
+ break
-def output_stats_html(urls):
+def output_stats_html(urls, lines):
print
print 'URL statistics:'
print '<table border="1">'
@@ -286,12 +301,19 @@
]
urls.sort()
urls.reverse()
+ line = 0
for (_, url, times) in urls:
if times.impact > 0 or times.hangs:
- print '<tr>'
+ if line%2:
+ print '<tr style="background: lightgrey;">'
+ else:
+ print '<tr>'
times.html()
print td(url)
print '</tr>'
+ line += 1
+ if line > lines:
+ break
print '</table>'
def minutes_header_text():
@@ -330,8 +352,14 @@
def td(*values):
return ''.join([("<td>%s</td>" % s) for s in values])
+output_minute_count = 0
def output_minute_html(lmin, requests, input, wait, apps, output, n, spr, spa):
- print '<tr>'
+ global output_minute_count
+ output_minute_count += 1
+ if output_minute_count%2:
+ print '<tr style="background: lightgrey">'
+ else:
+ print '<tr>'
apps = '<font size="+2"><strong>%s</strong></font>' % apps
print td(lmin.replace('T', ' '), len(requests), input, wait, apps, output)
if n:
@@ -474,6 +502,13 @@
help="""
A prefex to be removed from URLS.
""")
+parser.add_option("--summary-only", dest='summary_only', action='store_true',
+ help="""
+Only output summary lines.
+""")
+parser.add_option("--summary-lines", dest='summary_lines',
+ type="int", default=999999999,
+ help="""The number of summary lines to show""")
More information about the Checkins
mailing list