From b6639792471d50a0326c7e9bd6cef8c2b74499db Mon Sep 17 00:00:00 2001 From: Marius Sturm Date: Thu, 7 Apr 2016 17:01:11 +0200 Subject: [PATCH] use microseconds for request_duration, to be consistent with mod_log_config --- README.md | 5 ++--- src/functions20.h | 2 +- src/mod_log_gelf.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8bf998d..fc58849 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ What does the `GelfFields` string mean: | C | Connection status | | c | Extract Cookie | | D | Request duration | +| | (in microseconds) | | f | Requested file | | H | Protocol | | h | Remote host | @@ -121,9 +122,7 @@ Bundle module and configuration files to system package, e.g. for Ubuntu: Install dependent c libraries: ``` - $ sudo apt-get install apache2-dev - $ sudo apt-get install libjson-c-dev - $ sudo apt-get install zlib1g-dev + $ sudo apt-get install apache2-dev libjson-c-dev zlib1g-dev ``` Compile and install modules: diff --git a/src/functions20.h b/src/functions20.h index 4e2a5c7..bc586dd 100644 --- a/src/functions20.h +++ b/src/functions20.h @@ -85,7 +85,7 @@ static const char *extract_request_time(request_rec *r, char *a) static const char *extract_request_duration(request_rec *r, char *a) { apr_time_t duration = apr_time_now() - r->request_time; - return apr_psprintf(r->pool, "%.3lf", apr_time_usec(duration)/1000.0); + return apr_psprintf(r->pool, "%ld", apr_time_usec(duration)); } static const char *extract_connection_status(request_rec *r, char *a) __attribute__((unused)); diff --git a/src/mod_log_gelf.c b/src/mod_log_gelf.c index 8d223c9..152ae13 100644 --- a/src/mod_log_gelf.c +++ b/src/mod_log_gelf.c @@ -389,7 +389,7 @@ static int log_gelf_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte log_gelf_register_item(server,p,'B', extract_bytes_sent, NULL, "_bytes_send"); log_gelf_register_item(server,p,'C', extract_connection_status, NULL, "_connection_status"); log_gelf_register_item(server,p,'c', extract_specific_cookie, config->cookie, "_cookie"); - log_gelf_register_item(server,p,'D', extract_request_duration, NULL, "_request_duration_ms"); + log_gelf_register_item(server,p,'D', extract_request_duration, NULL, "_request_duration_us"); log_gelf_register_item(server,p,'f', extract_request_file, NULL, "_request_file"); log_gelf_register_item(server,p,'H', extract_request_protocol, NULL, "_request_protocol"); log_gelf_register_item(server,p,'h', extract_remote_host, NULL, "_remote_host");