Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stats: Do not expand dots of tm_name #10316

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/output-json-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "util-print.h"
#include "util-time.h"
#include "util-unittest.h"
#include "util-validate.h"

#include "util-debug.h"
#include "output.h"
Expand Down Expand Up @@ -265,20 +266,30 @@ json_t *StatsToJSON(const StatsTable *st, uint8_t flags)
for (x = 0; x < st->ntstats; x++) {
uint32_t offset = x * st->nstats;

// Stats for for this thread.
json_t *thread = json_object();
if (unlikely(thread == NULL)) {
json_decref(js_stats);
json_decref(threads);
return NULL;
}

/* for each counter */
for (u = offset; u < (offset + st->nstats); u++) {
if (st->tstats[u].name == NULL)
continue;

// Seems this holds, but assert in debug builds.
DEBUG_VALIDATE_BUG_ON(
strcmp(st->tstats[offset].tm_name, st->tstats[u].tm_name) != 0);

json_t *js_type = NULL;
const char *stat_name = st->tstats[u].short_name;
if (st->tstats[u].short_name == NULL) {
stat_name = st->tstats[u].name;
js_type = threads;
} else {
char str[256];
snprintf(str, sizeof(str), "%s.%s", st->tstats[u].tm_name, st->tstats[u].name);
js_type = OutputStats2Json(threads, str);
js_type = OutputStats2Json(thread, st->tstats[u].name);
}

if (js_type != NULL) {
Expand All @@ -292,6 +303,7 @@ json_t *StatsToJSON(const StatsTable *st, uint8_t flags)
}
}
}
json_object_set_new(threads, st->tstats[offset].tm_name, thread);
}
json_object_set_new(js_stats, "threads", threads);
}
Expand Down