microseconds patch

Shawn Michael <smichael-icIElDLue0NWk0Htik3J/[email protected]> Tue, 25 Jan 2005 23:16:26 -0700
Newsgroups gmane.comp.apache.mod-log-sql
Organization RightNow Technologies, Inc.
Message-ID <[email protected]>
Attached is a patch against 1.99 to add support for the microseconds duration 
option present in apache 2.0.  The patch does apply cleanly to 1.100 so it should 
be easily tested against that version.

It alters the schema a bit and adds the log format option "D" which corresponds 
to the apache 2.0 microseconds log format string.  It should be noted that it 
looks to be either or for logging time.  Either microseconds or whole seconds can 
be logged.  The new column name is request_duration_ms and should be a relatively 
large number.

Since I also got the whole milli vs micro confused in my head... To get the 
number of seconds divide the number in the request_duration_ms column by 
1,000,000 and tada -- Seconds ;)

As a side note we have been doing numerous tests with apache to try to determine 
exactly what apache records for it's time fields.  Apache records the time from 
start of transaction until it can write the last byte to the network buffers.  If 
you want to "cheat" a little you can improve your reported performance stats by 
adding:
	SendBufferSize 131071

to the main section of your httpd.conf file.  The default buffer size is 16k and 
increasing it to 128k will help your stats out considerably.  Most pages fit into 
this buffer size so apache will report what it took to get the page out and 
doesn't count the slow connection speed of the client.

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Shawn Michael                                   smichael-icIElDLue0NWk0Htik3J/[email protected]
RightNow Technologies                           Hosting Administrator
                                  A Better Way to Serve your Customers

_______________________________________________
Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/

To unsubscribe send an e-mail to 
mod_log_sql-unsubscribe-7qY7E20V6GW73k+5HYS8LQqVMODqnSLI@public.gmane.org
microseconds.patch (text/x-patch, 3.6 KB)
diff -x .svn --recursive --unified mod_log_sql/contrib/create_tables.sql mod_log_sql.new/contrib/create_tables.sql
--- mod_log_sql/contrib/create_tables.sql	2004-11-24 15:34:22.000000000 -0700
+++ mod_log_sql.new/contrib/create_tables.sql	2004-11-24 15:16:04.000000000 -0700
@@ -23,7 +23,8 @@
 	ssl_maxkeysize smallint unsigned,
 	status smallint unsigned ,
 	time_stamp int unsigned ,
-	virtual_host varchar(255)
+	virtual_host varchar(255) ,
+    request_duration_ms int unsigned
 );
 
 create table notes (
diff -x .svn --recursive --unified mod_log_sql/functions20.h mod_log_sql.new/functions20.h
--- mod_log_sql/functions20.h	2004-11-24 15:34:24.000000000 -0700
+++ mod_log_sql.new/functions20.h	2004-11-24 15:06:12.000000000 -0700
@@ -96,6 +96,14 @@
 	return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_sec(duration));
 }
 
+
+static const char *extract_request_duration_microseconds(request_rec *r, char *a)
+{
+    return apr_psprintf(r->pool, "%" APR_TIME_T_FMT,
+                        (apr_time_now() - r->request_time));
+}
+
+
 static const char *extract_request_timestamp(request_rec *r, char *a)
 {
 	return apr_psprintf(r->pool, "%"APR_TIME_T_FMT, apr_time_sec(apr_time_now()));
diff -x .svn --recursive --unified mod_log_sql/mod_log_sql.c mod_log_sql.new/mod_log_sql.c
--- mod_log_sql/mod_log_sql.c	2004-11-24 15:34:24.000000000 -0700
+++ mod_log_sql.new/mod_log_sql.c	2004-11-24 15:09:55.000000000 -0700
@@ -490,6 +490,9 @@
     log_sql_register_item(s,p,'U', extract_request_uri,       "request_uri",      1, 1);
     log_sql_register_item(s,p,'v', extract_virtual_host,      "virtual_host",     0, 1);
     log_sql_register_item(s,p,'V', extract_server_name,       "virtual_host",     0, 1);
+#if defined(WITH_APACHE20)
+    log_sql_register_item(s,p,'D', extract_request_duration_microseconds,  "request_duration_ms", 1, 0);
+#endif
 
     if (global_config.announce) {
         ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION);
diff -x .svn --recursive --unified mod_log_sql/mod_log_sql_dbi.c mod_log_sql.new/mod_log_sql_dbi.c
--- mod_log_sql/mod_log_sql_dbi.c	2004-11-24 15:34:24.000000000 -0700
+++ mod_log_sql.new/mod_log_sql_dbi.c	2004-11-24 15:13:37.000000000 -0700
@@ -180,7 +180,8 @@
        ssl_maxkeysize smallint unsigned,\
        status smallint unsigned,\
        time_stamp int unsigned,\
-       virtual_host varchar(255))";
+       virtual_host varchar(255),\
+       request_duration_ms int unsigned)";
 		break;
 	case LOGSQL_TABLE_COOKIES:
 	case LOGSQL_TABLE_HEADERSIN:
diff -x .svn --recursive --unified mod_log_sql/mod_log_sql_mysql.c mod_log_sql.new/mod_log_sql_mysql.c
--- mod_log_sql/mod_log_sql_mysql.c	2004-11-24 15:34:24.000000000 -0700
+++ mod_log_sql.new/mod_log_sql_mysql.c	2004-11-24 15:37:52.000000000 -0700
@@ -210,7 +210,8 @@
        ssl_maxkeysize smallint unsigned,\
        status smallint unsigned,\
        time_stamp int unsigned,\
-       virtual_host varchar(255))";
+       virtual_host varchar(255),\
+       request_duration_ms int unsigned)";
 		break;
 	case LOGSQL_TABLE_COOKIES:
 	case LOGSQL_TABLE_HEADERSIN:
diff -x .svn --recursive --unified mod_log_sql/mod_log_sql_pgsql.c mod_log_sql.new/mod_log_sql_pgsql.c
--- mod_log_sql/mod_log_sql_pgsql.c	2004-11-24 15:34:24.000000000 -0700
+++ mod_log_sql.new/mod_log_sql_pgsql.c	2004-11-24 15:14:49.000000000 -0700
@@ -195,7 +195,8 @@
        ssl_maxkeysize smallint unsigned,\
        status smallint unsigned,\
        time_stamp int unsigned,\
-       virtual_host varchar(255))";
+       virtual_host varchar(255),\
+       request_duration_ms int unsigned)";
 		break;
 	case LOGSQL_TABLE_COOKIES:
 	case LOGSQL_TABLE_HEADERSIN:
smime.p7s (application/x-pkcs7-signature, 3.1 KB) - not displayed