Skip to content

Commit

Permalink
WT-3575 ASCII statistics log printing (#3652)
Browse files Browse the repository at this point in the history
* WT-3575 ASCII statistics log printing

Add a test for JSON configuration before logging the table name in
JSON format.

Minor KNF/whitespace.

* When logging statistics, log them in JSON format, that's our default now.

When logging statistics, log them when closing down the system.
  • Loading branch information
keithbostic committed Sep 12, 2017
1 parent 41d6785 commit d686015
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/conn/conn_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ __statlog_print_table_name(

conn = S2C(session);

if (!FLD_ISSET(conn->stat_flags, WT_STAT_JSON))
return (0);

/*
* If printing the connection stats, write that header and we are done.
*/
Expand All @@ -282,8 +285,8 @@ __statlog_print_table_name(

/*
* If this is the first table we are printing stats for print the header
* for the wiredTigerTables section. Otherwise print a comma as this
* is a subsequent table.
* for the wiredTigerTables section. Otherwise print a comma as this is
* a subsequent table.
*/
if (conn->stat_json_tables)
WT_RET(__wt_fprintf(session, conn->stat_fs,","));
Expand Down Expand Up @@ -386,11 +389,10 @@ __statlog_dump(WT_SESSION_IMPL *session, const char *name, bool conn_stats)
"%s\"%s\":%" PRId64,
groupfirst ? "" : ",", endprefix + 2, val));
groupfirst = false;
} else {
} else
WT_ERR(__wt_fprintf(session, conn->stat_fs,
"%s %" PRId64 " %s %s\n",
conn->stat_stamp, val, name, desc));
}
}
WT_ERR_NOTFOUND_OK(ret);
if (FLD_ISSET(conn->stat_flags, WT_STAT_JSON))
Expand Down
7 changes: 4 additions & 3 deletions test/format/wts.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ wts_open(const char *home, bool set_api, WT_CONNECTION **connp)
if (mmrand(NULL, 0, 5) == 1 &&
memcmp(g.uri, "file:", strlen("file:")) == 0)
CONFIG_APPEND(p,
",statistics=(fast)"
",statistics_log=(wait=5,sources=(\"file:\"))");
",statistics=(fast),statistics_log="
"(json,on_close,wait=5,sources=(\"file:\"))");
else
CONFIG_APPEND(p,
",statistics=(fast),statistics_log=(wait=5)");
",statistics=(fast),statistics_log="
"(json,on_close,wait=5)");
} else
CONFIG_APPEND(p,
",statistics=(%s)", g.c_statistics ? "fast" : "none");
Expand Down

0 comments on commit d686015

Please sign in to comment.