Skip to content

Commit 2516468

Browse files
committed
Add metric for tagged requests over cdb2api
Signed-off-by: Mike Ponomarenko <[email protected]>
1 parent d156703 commit 2516468

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

db/comdb2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ long n_bad_swapin;
511511
long n_retries;
512512
long n_missed;
513513
long n_dbinfo;
514+
int64_t n_tagged_over_cdb2api = 0;
514515

515516
int n_commits;
516517
long long n_commit_time; /* in micro seconds.*/

db/comdb2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,7 @@ extern long n_bad_swapin;
17381738
extern long n_retries;
17391739
extern long n_missed;
17401740
extern long n_dbinfo;
1741+
extern int64_t n_tagged_over_cdb2api;
17411742
extern history *reqhist;
17421743
extern int gbl_sbuftimeout;
17431744
extern int sqldbgflag;

db/db_metrics.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct comdb2_metrics_store {
148148
int64_t fastsql_sslconn;
149149
int64_t fastsql_execute_stop;
150150
int64_t legacy_requests;
151+
int64_t tagged_cdb2api;
151152
};
152153

153154
static struct comdb2_metrics_store stats;
@@ -378,6 +379,9 @@ comdb2_metric gbl_metrics[] = {
378379
&stats.legacy_requests, NULL},
379380
{"max_current_connections", "Max current connections for sampled interval", STATISTIC_INTEGER,
380381
STATISTIC_COLLECTION_TYPE_LATEST, &stats.max_current_connections, NULL},
382+
{"tagged_over_cdb2api", "Number of tagged requests over cdb2api", STATISTIC_INTEGER,
383+
STATISTIC_COLLECTION_TYPE_LATEST, &stats.tagged_cdb2api, NULL},
384+
381385
};
382386

383387
const char *metric_collection_type_string(comdb2_collection_type t) {
@@ -712,6 +716,7 @@ int refresh_metrics(void)
712716

713717
update_fastsql_metrics();
714718
stats.max_current_connections = time_metric_max(thedb->connections);
719+
stats.tagged_cdb2api = n_tagged_over_cdb2api;
715720

716721
return 0;
717722
}

plugins/newsql/newsql_evbuffer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,6 @@ static int dispatch_tagged(struct sqlclntstate *clnt)
505505
if (appdata->sqlquery == NULL || appdata->sqlquery->n_bindvars < 3 || appdata->sqlquery->bindvars[0] == NULL ||
506506
appdata->sqlquery->bindvars[1] == NULL || appdata->sqlquery->bindvars[1]->value.len != sizeof(int) ||
507507
appdata->sqlquery->bindvars[2] == NULL || appdata->sqlquery->bindvars[2]->value.len != sizeof(int)) {
508-
// TODO
509-
// write error response: HOW
510-
// fprintf(stdout, ">> couldn't dispatch %d\n", __LINE__);
511508
return 1;
512509
}
513510
int luxref;
@@ -700,7 +697,9 @@ static void process_query(struct newsql_appdata_evbuffer *appdata)
700697
int have_sqlite_fmt = clnt->features.have_sqlite_fmt;
701698
clnt->sqlite_row_format = have_sqlite_fmt;
702699
clnt->is_tagged = sqlquery->has_is_tagged && sqlquery->is_tagged;
703-
if (!clnt->is_tagged)
700+
if (clnt->is_tagged)
701+
++n_tagged_over_cdb2api;
702+
else
704703
++clnt->sqltick;
705704

706705
/* If the connection is forwarded from a secure pmux port,

0 commit comments

Comments
 (0)