Skip to content

Commit c2180a4

Browse files
committed
feat(log): add action and proxy response time to log
1 parent 38d1d47 commit c2180a4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/mod_redirectionio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ static int redirectionio_match_handler(request_rec *r) {
134134
ctx->response_headers = NULL;
135135
ctx->body_filter = NULL;
136136
ctx->backend_response_status_code = 0;
137+
ctx->action_match_time = 0;
138+
ctx->proxy_response_time = 0;
137139

138140
ap_set_module_config(r->request_config, &redirectionio_module, ctx);
139141
redirectionio_connection* conn = redirectionio_acquire_connection(config, r->pool);
@@ -254,6 +256,7 @@ static apr_status_t redirectionio_filter_header_filtering(ap_filter_t *f, apr_bu
254256

255257
if (ctx->body_filter == NULL) {
256258
ctx->body_filter = (struct REDIRECTIONIO_FilterBodyAction *)redirectionio_action_body_filter_create(ctx->action, ctx->backend_response_status_code, ctx->response_headers);
259+
ctx->proxy_response_time = apr_time_now() / 1000;
257260

258261
// Force chunked encoding
259262
if (ctx->body_filter != NULL) {

src/mod_redirectionio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ typedef struct {
7676
struct REDIRECTIONIO_HeaderMap *response_headers;
7777
struct REDIRECTIONIO_FilterBodyAction *body_filter;
7878
uint16_t backend_response_status_code;
79+
apr_time_t action_match_time;
80+
apr_time_t proxy_response_time;
7981
} redirectionio_context;
8082

8183
module AP_MODULE_DECLARE_DATA redirectionio_module;

src/redirectionio_protocol.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ apr_status_t redirectionio_protocol_match(redirectionio_connection *conn, redire
147147

148148
// Unserialize action
149149
ctx->action = (struct REDIRECTIONIO_Action *)redirectionio_action_json_deserialize(action_serialized);
150+
ctx->action_match_time = apr_time_now() / 1000;
150151
}
151152

152153
return APR_SUCCESS;
@@ -163,7 +164,7 @@ apr_status_t redirectionio_protocol_log(redirectionio_connection *conn, redirect
163164
response = response->next;
164165
}
165166

166-
log = redirectionio_api_create_log_in_json(ctx->request, response->status, ctx->response_headers, ctx->action, PROXY_VERSION_STR(PROXY_VERSION), response->request_time / 1000, r->connection->client_ip);
167+
log = redirectionio_api_create_log_in_json(ctx->request, response->status, ctx->response_headers, ctx->action, PROXY_VERSION_STR(PROXY_VERSION), response->request_time / 1000, ctx->action_match_time, ctx->proxy_response_time, r->connection->client_ip);
167168

168169
if (log == NULL) {
169170
return APR_EGENERAL;

0 commit comments

Comments
 (0)