Commit 6df499ab authored by Marek Vavruša's avatar Marek Vavruša

daemon/worker: added new metrics (queries, dropped, timeout)

parent 2c5350cc
......@@ -682,6 +682,12 @@ static int wrk_stats(lua_State *L)
lua_setfield(L, -2, "ipv6");
lua_pushnumber(L, worker->stats.ipv4);
lua_setfield(L, -2, "ipv4");
lua_pushnumber(L, worker->stats.queries);
lua_setfield(L, -2, "queries");
lua_pushnumber(L, worker->stats.dropped);
lua_setfield(L, -2, "dropped");
lua_pushnumber(L, worker->stats.timeout);
lua_setfield(L, -2, "timeout");
return 1;
}
......
......@@ -178,6 +178,7 @@ void io_create(uv_loop_t *loop, uv_handle_t *handle, int type)
uv_udp_init(loop, (uv_udp_t *)handle);
} else {
uv_tcp_init(loop, (uv_tcp_t *)handle);
uv_tcp_nodelay((uv_tcp_t *)handle, 1);
}
}
......
......@@ -274,6 +274,7 @@ static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *ha
/* Start resolution */
kr_resolve_begin(&task->req, &engine->resolver, answer);
worker->stats.concurrent += 1;
worker->stats.queries += 1;
return task;
}
......@@ -337,6 +338,8 @@ static void on_timeout(uv_timer_t *req)
DEBUG_MSG("ioreq timeout %s %s %p\n", qname_str, type_str, req);
#endif
if (!uv_is_closing(handle)) {
struct worker_ctx *worker = task->worker;
worker->stats.queries += 1;
qr_task_step(task, NULL, NULL);
}
}
......@@ -593,6 +596,7 @@ int worker_exec(struct worker_ctx *worker, uv_handle_t *handle, knot_pkt_t *quer
/* Ignore badly formed queries or responses. */
if (ret != 0 || knot_wire_get_qr(query->wire)) {
DEBUG_MSG("task bad_query %p => %d, %s\n", task, ret, kr_strerror(ret));
worker->stats.dropped += 1;
return kr_error(EINVAL); /* Ignore. */
}
task = qr_task_create(worker, handle, query, addr);
......
......@@ -42,6 +42,9 @@ struct worker_ctx {
size_t tcp;
size_t ipv4;
size_t ipv6;
size_t queries;
size_t dropped;
size_t timeout;
} stats;
mp_freelist_t pools;
mp_freelist_t ioreqs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment