Add protocol packet statistics to servers
The individual servers were missing a statistic that would give an estimated query count. As there is no simple way to count queries for all modules, counting the number of routed protocol packets is a suitable substitute.
This commit is contained in:
parent
8c9aa82a69
commit
121d255780
@ -63,6 +63,7 @@ typedef struct
|
||||
int n_persistent; /**< Current persistent pool */
|
||||
uint64_t n_new_conn; /**< Times the current pool was empty */
|
||||
uint64_t n_from_pool; /**< Times when a connection was available from the pool */
|
||||
uint64_t packets; /**< Number of packets routed to this server */
|
||||
} SERVER_STATS;
|
||||
|
||||
/**
|
||||
|
@ -566,6 +566,7 @@ dprintServer(DCB *dcb, const SERVER *server)
|
||||
dcb_printf(dcb, "\tNumber of connections: %d\n", server->stats.n_connections);
|
||||
dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current);
|
||||
dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops);
|
||||
dcb_printf(dcb, "\tNumber of routed packets: %lu\n", server->stats.packets);
|
||||
if (server->persistpoolmax)
|
||||
{
|
||||
dcb_printf(dcb, "\tPersistent pool size: %d\n", server->stats.n_persistent);
|
||||
@ -1459,6 +1460,7 @@ static json_t* server_json_attributes(const SERVER* server)
|
||||
json_object_set_new(stats, "connections", json_integer(server->stats.n_current));
|
||||
json_object_set_new(stats, "total_connections", json_integer(server->stats.n_connections));
|
||||
json_object_set_new(stats, "active_operations", json_integer(server->stats.n_current_ops));
|
||||
json_object_set_new(stats, "routed_packets", json_integer(server->stats.packets));
|
||||
|
||||
json_object_set_new(attr, "statistics", stats);
|
||||
|
||||
|
@ -589,6 +589,9 @@ routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queu
|
||||
|
||||
inst->stats.n_queries++;
|
||||
|
||||
// Due to the streaming nature of readconnroute, this is not accurate
|
||||
atomic_add_uint64(&router_cli_ses->backend->server->stats.packets, 1);
|
||||
|
||||
/** Dirty read for quick check if router is closed. */
|
||||
if (router_cli_ses->rses_closed)
|
||||
{
|
||||
|
@ -366,6 +366,7 @@ bool route_session_write(RWSplitSession *rses, GWBUF *querybuf,
|
||||
if (backend->execute_session_command())
|
||||
{
|
||||
nsucc += 1;
|
||||
atomic_add_uint64(&backend->server()->stats.packets, 1);
|
||||
|
||||
if (expecting_response)
|
||||
{
|
||||
@ -1183,6 +1184,7 @@ bool handle_got_target(RWSplit *inst, RWSplitSession *rses,
|
||||
}
|
||||
|
||||
atomic_add_uint64(&inst->stats().n_queries, 1);
|
||||
atomic_add_uint64(&target->server()->stats.packets, 1);
|
||||
|
||||
if (!rses->large_query && response == mxs::Backend::EXPECT_RESPONSE)
|
||||
{
|
||||
|
@ -443,6 +443,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket)
|
||||
{
|
||||
/** Add one query response waiter to backend reference */
|
||||
atomic_add(&m_router->m_stats.n_queries, 1);
|
||||
atomic_add_uint64(&bref->server()->stats.packets, 1);
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
@ -743,6 +744,7 @@ bool SchemaRouterSession::route_session_write(GWBUF* querybuf, uint8_t command)
|
||||
if ((*it)->execute_session_command())
|
||||
{
|
||||
succp = true;
|
||||
atomic_add_uint64(&(*it)->server()->stats.packets, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user