Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate Request Latency #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void script_request(lua_State *L, char **buf, size_t *len) {
lua_pop(L, pop);
}

void script_response(lua_State *L, int status, buffer *headers, buffer *body) {
void script_response(lua_State *L, int status, buffer *headers, buffer *body, uint64_t req_latency) {
lua_getglobal(L, "response");
lua_pushinteger(L, status);
lua_newtable(L);
Expand All @@ -176,7 +176,8 @@ void script_response(lua_State *L, int status, buffer *headers, buffer *body) {
}

lua_pushlstring(L, body->buffer, body->cursor - body->buffer);
lua_call(L, 3, 0);
lua_pushnumber(L, req_latency);
lua_call(L, 4, 0);

buffer_reset(headers);
buffer_reset(body);
Expand Down
2 changes: 1 addition & 1 deletion src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void script_done(lua_State *, stats *, stats *);
void script_init(lua_State *, thread *, int, char **);
uint64_t script_delay(lua_State *);
void script_request(lua_State *, char **, size_t *);
void script_response(lua_State *, int, buffer *, buffer *);
void script_response(lua_State *, int, buffer *, buffer *, uint64_t);
size_t script_verify_request(lua_State *L);

bool script_is_static(lua_State *);
Expand Down
2 changes: 1 addition & 1 deletion src/wrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int response_complete(http_parser *parser) {

if (c->headers.buffer) {
*c->headers.cursor++ = '\0';
script_response(thread->L, status, &c->headers, &c->body);
script_response(thread->L, status, &c->headers, &c->body, now - c->start);
c->state = FIELD;
}

Expand Down