Adding more internal statistics

pull/2030/head
René Cannaò 7 years ago
parent 528d8cac38
commit 6e34814d34

@ -84,6 +84,12 @@ class MySQL_Data_Stream
unsigned long long wait_until;
unsigned long long killed_at;
unsigned long long max_connect_time;
struct {
unsigned long long questions;
unsigned long long myconnpoll_get;
unsigned long long myconnpoll_put;
} statuses;
PtrSizeArray *PSarrayIN;
PtrSizeArray *PSarrayOUT;
@ -180,6 +186,7 @@ class MySQL_Data_Stream
// safe way to attach a MySQL Connection
void attach_connection(MySQL_Connection *mc) {
statuses.myconnpoll_get++;
myconn=mc;
mc->myds=this;
}
@ -187,6 +194,7 @@ class MySQL_Data_Stream
// safe way to detach a MySQL Connection
void detach_connection() {
assert(myconn);
statuses.myconnpoll_put++;
myconn->myds=NULL;
myconn=NULL;
}

@ -739,12 +739,15 @@ void MySQL_Session::generate_proxysql_internal_session_json(json &j) {
j["backends"][i]["hostgroup_id"] = _mybe->hostgroup_id;
if (_mybe->server_myds) {
MySQL_Data_Stream *_myds=_mybe->server_myds;
j["backends"][i]["stream"]["questions"] = _myds->statuses.questions;
j["backends"][i]["stream"]["myconnpoll_get"] = _myds->statuses.myconnpoll_get;
j["backends"][i]["stream"]["myconnpoll_put"] = _myds->statuses.myconnpoll_put;
/* when fast_forward is not used, these metrics are always 0. Explicitly disabled
j["backend"][i]["stream"]["pkts_recv"] = _myds->pkts_recv;
j["backend"][i]["stream"]["pkts_sent"] = _myds->pkts_sent;
j["backend"][i]["stream"]["bytes_recv"] = _myds->bytes_info.bytes_recv;
j["backend"][i]["stream"]["bytes_sent"] = _myds->bytes_info.bytes_sent;
*/
j["backends"][i]["stream"]["bytes_recv"] = _myds->bytes_info.bytes_recv;
j["backends"][i]["stream"]["bytes_sent"] = _myds->bytes_info.bytes_sent;
if (_myds->myconn) {
MySQL_Connection * _myconn = _myds->myconn;
j["backends"][i]["conn"]["sql_mode"] = ( _myconn->options.sql_mode ? _myconn->options.sql_mode : "") ;
@ -2644,6 +2647,7 @@ __get_pkts_from_client:
}
}
mybe->server_myds->mysql_real_query.init(&pkt);
mybe->server_myds->statuses.questions++;
client_myds->setDSS_STATE_QUERY_SENT_NET();
} else {
switch (session_type) {
@ -2774,6 +2778,7 @@ __get_pkts_from_client:
mybe->server_myds->killed_at=0;
mybe->server_myds->kill_type=0;
mybe->server_myds->mysql_real_query.init(&pkt); // fix memory leak for PREPARE in prepared statements #796
mybe->server_myds->statuses.questions++;
client_myds->setDSS_STATE_QUERY_SENT_NET();
}
GloMyStmt->unlock();

@ -792,6 +792,7 @@ handler_again:
__sync_fetch_and_add(&parent->queries_sent,1);
__sync_fetch_and_add(&parent->bytes_sent,query.length);
myds->sess->thread->status_variables.queries_backends_bytes_sent+=query.length;
myds->bytes_info.bytes_sent += query.length;
if (myds->sess->with_gtid == true) {
__sync_fetch_and_add(&parent->queries_gtid_sync,1);
}
@ -823,6 +824,7 @@ handler_again:
__sync_fetch_and_add(&parent->queries_sent,1);
__sync_fetch_and_add(&parent->bytes_sent,query.length);
myds->sess->thread->status_variables.queries_backends_bytes_sent+=query.length;
myds->bytes_info.bytes_sent += query.length;
if (async_exit_status) {
next_event(ASYNC_STMT_PREPARE_CONT);
} else {
@ -855,6 +857,7 @@ handler_again:
__sync_fetch_and_add(&parent->queries_sent,1);
__sync_fetch_and_add(&parent->bytes_sent,query.stmt_meta->size);
myds->sess->thread->status_variables.queries_backends_bytes_sent+=query.stmt_meta->size;
myds->bytes_info.bytes_sent += query.stmt_meta->size;
if (async_exit_status) {
next_event(ASYNC_STMT_EXECUTE_CONT);
} else {
@ -917,6 +920,7 @@ handler_again:
}
__sync_fetch_and_add(&parent->bytes_recv,total_size);
myds->sess->thread->status_variables.queries_backends_bytes_recv+=total_size;
myds->bytes_info.bytes_recv += total_size;
}
}
/*
@ -1039,6 +1043,7 @@ handler_again:
unsigned int br=MyRS->add_row(mysql_row);
__sync_fetch_and_add(&parent->bytes_recv,br);
myds->sess->thread->status_variables.queries_backends_bytes_recv+=br;
myds->bytes_info.bytes_recv += br;
processed_bytes+=br; // issue #527 : this variable will store the amount of bytes processed during this event
if (
(processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8)

@ -217,6 +217,10 @@ MySQL_Data_Stream::MySQL_Data_Stream() {
CompPktOUT.partial=0;
multi_pkt.ptr=NULL;
multi_pkt.size=0;
statuses.questions = 0;
statuses.myconnpoll_get = 0;
statuses.myconnpoll_put = 0;
}
// Destructor

Loading…
Cancel
Save